accessibilityIndexForCharpos: walked composed character sequences from run.ax_start up to the target charpos offset. For a run covering an entire ASCII buffer, chars_in = pt - BUF_BEGV, making each call O(cursor_position). This method is called from ensureTextCache on EVERY redisplay frame (as part of the cache validity check), making each frame O(position) even when the buffer is completely unchanged. At line 34,000 of a large file this is ~1,000,000 iterations per frame. Fix: when ax_length == length for a run (all single-unit characters), the ax_index is simply ax_start + chars_in. O(1) instead of O(N). This is the symmetric counterpart to the charposForAccessibilityIndex: fast path added in the previous commit. Both conversion directions now run in O(1) for pure-ASCII buffers.
19 KiB
19 KiB