use cache to store char-to-column mapping

This is faster by O(n) to O(n²) compared to the previous algorithm
that would re-compute the column for each call.
This commit is contained in:
2021-12-20 20:09:29 +01:00
parent ffea831e2d
commit ba241b12e0
2 changed files with 18 additions and 4 deletions

View File

@@ -45,7 +45,10 @@ class HighlightSelection(Highlight):
start_column = line.char_to_column(start_char)
end_column = line.char_to_column(end_char)
length_in_columns = end_column - start_column
if end_column >= 0:
length_in_columns = end_column - start_column
else:
length_in_columns = 4096
return [HighlightedRange(start_column, length_in_columns, brush=QBrush(QColor(156, 215, 255, 192)),
pen=Qt.PenStyle.NoPen)]