Browse Source

Minor performance improvement for AvalonEdit (e.g. when indenting all lines in the file).

pull/14/head
Daniel Grunwald 15 years ago
parent
commit
f4b0c54f2d
  1. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs
  2. 9
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  3. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs

@ -110,8 +110,10 @@ namespace ICSharpCode.AvalonEdit.Document @@ -110,8 +110,10 @@ namespace ICSharpCode.AvalonEdit.Document
/// </summary>
public int GetNewOffset(int offset, AnchorMovementType movementType)
{
foreach (OffsetChangeMapEntry entry in this) {
offset = entry.GetNewOffset(offset, movementType);
IList<OffsetChangeMapEntry> items = this.Items;
int count = items.Count;
for (int i = 0; i < count; i++) {
offset = items[i].GetNewOffset(offset, movementType);
}
return offset;
}

9
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -86,6 +86,15 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -86,6 +86,15 @@ namespace ICSharpCode.AvalonEdit.Editing
}
}
/// <summary>
/// Gets the caret position without validating it.
/// </summary>
internal TextViewPosition NonValidatedPosition {
get {
return position;
}
}
/// <summary>
/// Gets/Sets the location of the caret.
/// The getter of this property is faster than <see cref="Position"/> because it doesn't have

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

@ -320,7 +320,9 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -320,7 +320,9 @@ namespace ICSharpCode.AvalonEdit.Editing
public RestoreCaretAndSelectionUndoAction(TextArea textArea)
{
this.textAreaReference = new WeakReference(textArea);
this.caretPosition = textArea.Caret.Position;
// Just save the old caret position, no need to validate here.
// If we restore it, we'll validate it anyways.
this.caretPosition = textArea.Caret.NonValidatedPosition;
this.selection = textArea.Selection;
}
@ -379,7 +381,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -379,7 +381,7 @@ namespace ICSharpCode.AvalonEdit.Editing
if (value == null)
throw new ArgumentNullException("value");
if (!object.Equals(selection, value)) {
Debug.WriteLine("Selection change from " + selection + " to " + value);
//Debug.WriteLine("Selection change from " + selection + " to " + value);
if (textView != null) {
ISegment oldSegment = selection.SurroundingSegment;
ISegment newSegment = value.SurroundingSegment;

Loading…
Cancel
Save