patches: fix O(overlays) performance regression

Performance issue: editing large files (>~10KB, >2000 lines) caused
progressive slowdown regardless of VoiceOver status.

Root causes:
1. ns_zoom_find_overlay_candidate_line: called Foverlays_in on the
   entire visible buffer range on every redisplay when UAZoomEnabled().
   In files with many overlays (font-lock, hl-line, show-paren etc.)
   this was O(overlays) Lisp work per keystroke.

2. postAccessibilityNotificationsForFrame: when ns-accessibility-enabled
   is non-nil, checked BUF_OVERLAY_MODIFF every redisplay. font-lock
   bumps this on every redraw, triggering ns_ax_selected_overlay_text
   (another O(overlays) scan) for non-minibuffer windows.

Fix: Both scans now guard with MINI_WINDOW_P check. Overlay completion
frameworks (Vertico, Icomplete, Ivy) only display candidates in
minibuffer windows --- no completion framework puts selected-face
overlays in normal editing buffers. For non-minibuffer windows both
functions return immediately with zero Lisp calls.

Additionally: ns_zoom_find_child_frame_candidate is skipped when
f->child_frame_list is nil (no child frames = no Corfu popup).
This commit is contained in:
2026-03-01 04:26:12 +01:00
parent 84eb777065
commit 3d2fa7a54e
9 changed files with 87 additions and 69 deletions

View File

@@ -1,4 +1,4 @@
From 4c7ddcb5e6f5905efefa55cb7188667744bd3d0e Mon Sep 17 00:00:00 2001
From ef42812ff2e18ac2492a679a47da350ace8fab54 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 6/9] ns: integrate accessibility with EmacsView and redisplay
@@ -51,10 +51,10 @@ index 80661a9..2b1f9e6 100644
** Re-introduced dictation, lost in Emacs v30 (macOS).
We lost macOS dictation in v30 when migrating to NSTextInputClient.
diff --git a/src/nsterm.m b/src/nsterm.m
index 4692a58..93da88a 100644
index 7fc542b..c35db76 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1343,6 +1343,9 @@ so the visual offset is (ov_line + 1) * line_h from
@@ -1352,6 +1352,9 @@ so the visual offset is (ov_line + 1) * line_h from
if (view)
ns_zoom_track_completion (f, view);
#endif /* NS_IMPL_COCOA */
@@ -64,7 +64,7 @@ index 4692a58..93da88a 100644
}
static void
@@ -7558,7 +7561,6 @@ - (id)accessibilityTopLevelUIElement
@@ -7567,7 +7570,6 @@ - (id)accessibilityTopLevelUIElement
@@ -72,7 +72,7 @@ index 4692a58..93da88a 100644
static BOOL
ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point,
ptrdiff_t *out_start,
@@ -8653,7 +8655,6 @@ - (NSRect)accessibilityFrame
@@ -8662,7 +8664,6 @@ - (NSRect)accessibilityFrame
@end
@@ -80,7 +80,7 @@ index 4692a58..93da88a 100644
/* ===================================================================
EmacsAccessibilityBuffer (Notifications) — AX event dispatch
@@ -9198,7 +9199,6 @@ - (NSRect)accessibilityFrame
@@ -9207,7 +9208,6 @@ - (NSRect)accessibilityFrame
@end
@@ -88,7 +88,7 @@ index 4692a58..93da88a 100644
/* ===================================================================
EmacsAccessibilityInteractiveSpan — helpers and implementation
=================================================================== */
@@ -9528,6 +9528,7 @@ - (void)dealloc
@@ -9537,6 +9537,7 @@ - (void)dealloc
[layer release];
#endif
@@ -96,7 +96,7 @@ index 4692a58..93da88a 100644
[[self menu] release];
[super dealloc];
}
@@ -10876,6 +10877,32 @@ - (void)windowDidBecomeKey /* for direct calls */
@@ -10885,6 +10886,32 @@ - (void)windowDidBecomeKey /* for direct calls */
XSETFRAME (event.frame_or_window, emacsframe);
kbd_buffer_store_event (&event);
ns_send_appdefined (-1); // Kick main loop
@@ -129,7 +129,7 @@ index 4692a58..93da88a 100644
}
@@ -12116,6 +12143,332 @@ - (int) fullscreenState
@@ -12125,6 +12152,332 @@ - (int) fullscreenState
return fs_state;
}