From 82cf750633468024da8f304fc5c956036c929f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C3=85=E2=84=A2=C3=83=C2=AD=20Techet?= Date: Tue, 9 Jun 2015 11:57:54 +0200 Subject: When combining MarkerHandlerSets, prepend the other set instead of appending When undoing many lines with markers (e.g. "changebar" markers) LineMarkers::RemoveLine() is called for many lines and as a result combining markers from the next line for all the removed lines. This may cause the list contains many thousands of elements and traversing it becomes expensive. When lines are removed from the beginning to the end, it's better to prepend the markers from the next line to the current line instead of appending them because the current line "accumulates" all the markers from the following lines and walking the whole list takes more and more time. --- src/PerLine.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PerLine.cxx b/src/PerLine.cxx index 8fd96cbed..14d89e100 100644 --- a/src/PerLine.cxx +++ b/src/PerLine.cxx @@ -108,11 +108,12 @@ bool MarkerHandleSet::RemoveNumber(int markerNum, bool all) { } void MarkerHandleSet::CombineWith(MarkerHandleSet *other) { - MarkerHandleNumber **pmhn = &root; + MarkerHandleNumber **pmhn = &other->root; while (*pmhn) { pmhn = &((*pmhn)->next); } - *pmhn = other->root; + *pmhn = root; + root = other->root; other->root = 0; } -- cgit v1.2.3