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:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user