bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58558: 29.0.50; re-search-forward is slow in some buffers


From: Stefan Monnier
Subject: bug#58558: 29.0.50; re-search-forward is slow in some buffers
Date: Wed, 12 Apr 2023 10:06:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> 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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]