From 5ddbd8d191e7e38167a63728c6ead5a6401c63f6 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Sun, 20 Oct 2019 16:55:26 +0000 Subject: [PATCH] Optimize c-crosses-statement-barrier-p for large blocks of comment. This fixes bug #18134. * lisp/progmodes/cc-engine.el (c-crosses-statement-barrier-p): Give a limit to the c-backward-syntactic-ws which is searching for a virtual semicolon. In the main loop, Use c-forward-syntactic-ws to skip blocks of comments. --- lisp/progmodes/cc-engine.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 8d92b26ebd0..cceb58c290a 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1468,10 +1468,14 @@ comment at the start of cc-engine.el for more info." (progn (if (setq lit-start (c-literal-start from)) ; Have we landed in a string/comment? (goto-char lit-start)) - (c-backward-syntactic-ws) ; ? put a limit here, maybe? + (c-backward-syntactic-ws (c-point 'bopl)) (setq vsemi-pos (point)) (c-at-vsemi-p)))) (throw 'done vsemi-pos)) + ;; Optimize for large blocks of comments. + ((progn (c-forward-syntactic-ws to) + (>= (point) to)) + (throw 'done nil)) ;; In a string/comment? ((setq lit-range (c-literal-limits from)) (goto-char (cdr lit-range))) -- 2.39.2