From e2ac00d7e452d30d4fc005647d503fd247c13ba5 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 17 May 2019 09:02:10 +1000 Subject: Optimize InsertLines and DeleteLines for ContractionState if no folds contracted. --- src/ContractionState.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index 565f9e141..8b5821470 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -210,16 +210,24 @@ Sci::Line ContractionState::DocFromDisplay(Sci::Line lineDisplay) const { template void ContractionState::InsertLines(Sci::Line lineDoc, Sci::Line lineCount) { - for (Sci::Line l = 0; l < lineCount; l++) { - InsertLine(lineDoc + l); + if (OneToOne()) { + linesInDocument += static_cast(lineCount); + } else { + for (Sci::Line l = 0; l < lineCount; l++) { + InsertLine(lineDoc + l); + } } Check(); } template void ContractionState::DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) { - for (Sci::Line l = 0; l < lineCount; l++) { - DeleteLine(lineDoc); + if (OneToOne()) { + linesInDocument -= static_cast(lineCount); + } else { + for (Sci::Line l = 0; l < lineCount; l++) { + DeleteLine(lineDoc); + } } Check(); } -- cgit v1.2.3