Improve performance of TextStepper,

stepping line by line instead of character by character,
delegating the scan for line breaks to native string search
(~15-100x speedup for a full pass over typical source files)
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-15 19:00:31 +02:00
1 parent 97c9b8c05d
commit d4e99dc003
2 files changed
+65 -37

No files matched your search

+2
View File
@@ -20,6 +20,8 @@ class TestTextUtils:
assert lines[i][len(self.LINE) :] == ending
def test_line_col_from_idx(self):
assert TextUtils.get_line_col_from_index(self.LINE, 0) == (0, 0)
assert TextUtils.get_line_col_from_index(self.LINE, 1) == (0, 1)
assert TextUtils.get_line_col_from_index(self.TEXT, 0) == (0, 0)
assert TextUtils.get_line_col_from_index(self.TEXT, 1) == (0, 1)
assert TextUtils.get_line_col_from_index(self.TEXT, 3 + 1 + 1) == (1, 1)