mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
optimize caret cloning - do a cheap check first
this makes EditorMultiCaretColumnModeTest.testPageMovementsInteroperateWithLineMovements work much faster, as position markers in CaretImpl are not created needlessly, and System.gc() in RangeMarkerTree.errMsg is not invoked
This commit is contained in:
@@ -840,6 +840,11 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable {
|
||||
public Caret clone(boolean above) {
|
||||
assertIsDispatchThread();
|
||||
int lineShift = above ? -1 : 1;
|
||||
LogicalPosition oldPosition = getLogicalPosition();
|
||||
int newLine = oldPosition.line + lineShift;
|
||||
if (newLine < 0 || newLine >= myEditor.getDocument().getLineCount()) {
|
||||
return null;
|
||||
}
|
||||
final CaretImpl clone = cloneWithoutSelection();
|
||||
final int newSelectionStartOffset;
|
||||
final int newSelectionEndOffset;
|
||||
@@ -875,12 +880,6 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable {
|
||||
newSelectionStartColumn = -1;
|
||||
newSelectionEndColumn = -1;
|
||||
}
|
||||
LogicalPosition oldPosition = getLogicalPosition();
|
||||
int newLine = oldPosition.line + lineShift;
|
||||
if (newLine < 0 || newLine >= myEditor.getDocument().getLineCount()) {
|
||||
Disposer.dispose(clone);
|
||||
return null;
|
||||
}
|
||||
clone.moveToLogicalPosition(new LogicalPosition(newLine, myLastColumnNumber), false, null, false);
|
||||
clone.myLastColumnNumber = myLastColumnNumber;
|
||||
clone.myDesiredX = myDesiredX >= 0 ? myDesiredX : getCurrentX();
|
||||
|
||||
Reference in New Issue
Block a user