patches: fix O(position) lag — O(1) fast path in charposForAccessibilityIndex:
charposForAccessibilityIndex: walked composed character sequences from the start of a visible run to the target AX index. For a run covering an entire ASCII buffer, this is O(cursor_position): moving to line 10,000 requires ~500,000 iterations per call. The method is called on every SelectedTextChanged notification response (accessibilityBoundsForRange: from the AX server for cursor tracking), making cursor movement O(position) in large files. Fix: when ax_length == length for a run (all characters are single AX index units — true for all ASCII/Latin text), the charpos offset is simply ax_idx - run.ax_start. O(1) instead of O(position). Multi-byte runs (emoji, CJK, non-BMP) fall back to the sequence walk, bounded by run length (visible window size), not total buffer size.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
From 85259296769fe8e30d3fa2d8a7626729023c8691 Mon Sep 17 00:00:00 2001
|
||||
From 35a32f4802822ee77350a6d652aa45cca38e304c Mon Sep 17 00:00:00 2001
|
||||
From: Martin Sukany <martin@sukany.cz>
|
||||
Date: Sat, 28 Feb 2026 16:01:29 +0100
|
||||
Subject: [PATCH 9/9] ns: announce child frame completion candidates for
|
||||
Subject: [PATCH 8/8] ns: announce child frame completion candidates for
|
||||
VoiceOver
|
||||
|
||||
Completion frameworks such as Corfu, Company-box, and similar
|
||||
@@ -109,7 +109,7 @@ index 2102fb9..dd98d56 100644
|
||||
@end
|
||||
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index 3e005e0..d61a634 100644
|
||||
index c74eaf1..d2f88a5 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -7398,6 +7398,112 @@ visual line index for Zoom (skip whitespace-only lines
|
||||
@@ -268,7 +268,7 @@ index 3e005e0..d61a634 100644
|
||||
cachedTextStart = start;
|
||||
|
||||
if (visibleRuns)
|
||||
@@ -9135,6 +9250,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
|
||||
@@ -9143,6 +9258,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
|
||||
ptrdiff_t currentOverlayStart = 0;
|
||||
ptrdiff_t currentOverlayEnd = 0;
|
||||
|
||||
@@ -276,7 +276,7 @@ index 3e005e0..d61a634 100644
|
||||
specpdl_ref count2 = SPECPDL_INDEX ();
|
||||
record_unwind_current_buffer ();
|
||||
if (b != current_buffer)
|
||||
@@ -9293,6 +9409,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
|
||||
@@ -9301,6 +9417,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
|
||||
self.cachedCompletionOverlayEnd = 0;
|
||||
self.cachedCompletionPoint = 0;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ index 3e005e0..d61a634 100644
|
||||
}
|
||||
|
||||
/* ---- Notification dispatch (main entry point) ---- */
|
||||
@@ -9889,6 +10006,10 @@ - (void)dealloc
|
||||
@@ -9897,6 +10014,10 @@ - (void)dealloc
|
||||
#endif
|
||||
|
||||
[accessibilityElements release];
|
||||
@@ -295,7 +295,7 @@ index 3e005e0..d61a634 100644
|
||||
[[self menu] release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -11338,6 +11459,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
|
||||
@@ -11346,6 +11467,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
|
||||
|
||||
windowClosing = NO;
|
||||
processingCompose = NO;
|
||||
@@ -305,7 +305,7 @@ index 3e005e0..d61a634 100644
|
||||
scrollbarsNeedingUpdate = 0;
|
||||
fs_state = FULLSCREEN_NONE;
|
||||
fs_before_fs = next_maximized = -1;
|
||||
@@ -12646,6 +12770,80 @@ - (id)accessibilityFocusedUIElement
|
||||
@@ -12654,6 +12778,80 @@ - (id)accessibilityFocusedUIElement
|
||||
The existing elements carry cached state (modiff, point) from the
|
||||
previous redisplay cycle. Rebuilding first would create fresh
|
||||
elements with current values, making change detection impossible. */
|
||||
@@ -386,7 +386,7 @@ index 3e005e0..d61a634 100644
|
||||
- (void)postAccessibilityUpdates
|
||||
{
|
||||
NSTRACE ("[EmacsView postAccessibilityUpdates]");
|
||||
@@ -12656,11 +12854,59 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12664,11 +12862,59 @@ - (void)postAccessibilityUpdates
|
||||
|
||||
/* Re-entrance guard: VoiceOver callbacks during notification posting
|
||||
can trigger redisplay, which calls ns_update_end, which calls us
|
||||
|
||||
Reference in New Issue
Block a user