GNU bug report logs - #58558
29.0.50; re-search-forward is slow in some buffers

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Sun, 16 Oct 2022 01:27:02 UTC

Severity: normal

Found in version 29.0.50

Full log


Message #194 received at 58558 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 58558 <at> debbugs.gnu.org, larsi <at> gnus.org, Ihor Radchenko <yantar92 <at> posteo.net>,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#58558: 29.0.50; re-search-forward is slow in some buffers
Date: Wed, 12 Apr 2023 10:06:03 -0400
> 1. emacs -Q
> 2. M-: (require 'cc-langs) <RET>
> 3. C-x b asd <RET>
> 4. M-: parse-sexp-lookup-properties <RET> => t
>
> On Emacs 28, (4) yields nil.

I suspect that the patch below might fix the immediate problem.
Of course, setting `parse-sexp-lookup-properties` should not have such
a major performance impact, so maybe we should keep digging into
the problem.


        Stefan


diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index aa6f33e9cab..92ab0c02de1 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -2153,20 +2153,13 @@ c-emacs-features
     ;; Record whether the `category' text property works.
     (if c-use-category (setq list (cons 'category-properties list)))
 
-    (let ((buf (generate-new-buffer " test"))
-	  parse-sexp-lookup-properties
-	  parse-sexp-ignore-comments
-	  lookup-syntax-properties)	; XEmacs
-      (with-current-buffer buf
+    (with-current-buffer (generate-new-buffer " test")
+      ;; Do the let-binding in the right buffer, in case they're buffer-local.
+      (let ((parse-sexp-lookup-properties t)
+	    (parse-sexp-ignore-comments t)
+	    (lookup-syntax-properties t))	; XEmacs
 	(set-syntax-table (make-syntax-table))
 
-	;; For some reason we have to set some of these after the
-	;; buffer has been made current.  (Specifically,
-	;; `parse-sexp-ignore-comments' in Emacs 21.)
-	(setq parse-sexp-lookup-properties t
-	      parse-sexp-ignore-comments t
-	      lookup-syntax-properties t)
-
 	;; Find out if the `syntax-table' text property works.
 	(modify-syntax-entry ?< ".")
 	(modify-syntax-entry ?> ".")
@@ -2231,8 +2224,8 @@ c-emacs-features
 	    (if (bobp)
 		(setq list (cons 'col-0-paren list)))))
 
-	(set-buffer-modified-p nil))
-      (kill-buffer buf))
+	(set-buffer-modified-p nil)
+	(kill-buffer (current-buffer))))
 
     ;; Check how many elements `parse-partial-sexp' returns.
     (let ((ppss-size (or (c-safe (length





This bug report was last modified 2 years and 63 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.