Closed xcb-xwii closed 3 months ago
With some more testing it seems that the 200x figure is way higher than it actually is. 200x was mostly really the profiler slowing the function down.
Actual figure is like around 3x though, so this is still pretty worth it.
@TorchedSammy any thoughts? i think this is good to go
Optimise calculation of byte lengths by:
Doc.get_text
-> avoid stutters on large files (only the first input might stutter a bit now, as the length needs to be calculated once first)#
instead ofstring.len
to get lengths -> reduces length of stutters SIGNIFICANTLY (by around 200x for all files)This avoids absolute terror when editing large files.
Without this change, when inserting at the end a 60k line file, 99%+ of time spent on inserting text into a document was just running
accumulateLen
:With this change, the cost of computing the byte lengths are much lower: