emacs-diffs
[Top][All Lists]
Advanced

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

master e7b4f46: Fix python-font-lock-keywords-maximum-decoration perform


From: Lars Ingebrigtsen
Subject: master e7b4f46: Fix python-font-lock-keywords-maximum-decoration performance regression
Date: Wed, 11 Nov 2020 06:28:19 -0500 (EST)

branch: master
commit e7b4f465e8b2ec1c8d54a611db7eca44ae350711
Author: Dario Gjorgjevski <dario.gjorgjevski@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix python-font-lock-keywords-maximum-decoration performance regression
    
    * lisp/progmodes/python.el
    (python-font-lock-keywords-maximum-decoration): `symbol-name'
    should not be quantified by a `+' as it is redundant and performs
    very badly (bug#44572).
---
 lisp/progmodes/python.el | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index eb84b49..a179318 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -662,14 +662,11 @@ builtins.")
     ;; assignments
     ;; support for a = b = c = 5
     (,(lambda (limit)
-        (let ((re (python-rx (group (+ symbol-name))
-                             (? ?\[ (+ (not ?\])) ?\])
-                             (* space)
-                             ;; A type, like " : int ".
-                             (? ?:
-                                (* space)
-                                (+ not-simple-operator)
-                                (* space))
+        (let ((re (python-rx (group symbol-name)
+                             ;; subscript, like "[5]"
+                             (? ?\[ (+ (not ?\])) ?\]) (* space)
+                             ;; type hint, like ": int" or ": Mapping[int, 
str]"
+                             (? ?: (* space) (+ not-simple-operator) (* space))
                              assignment-operator))
               (res nil))
           (while (and (setq res (re-search-forward re limit t))
@@ -679,9 +676,9 @@ builtins.")
      (1 font-lock-variable-name-face nil nil))
     ;; support for a, b, c = (1, 2, 3)
     (,(lambda (limit)
-        (let ((re (python-rx (group (+ symbol-name)) (* space)
-                             (* ?, (* space) (+ symbol-name) (* space))
-                             ?, (* space) (+ symbol-name) (* space)
+        (let ((re (python-rx (group symbol-name) (* space)
+                             (* ?, (* space) symbol-name (* space))
+                             ?, (* space) symbol-name (* space)
                              assignment-operator))
               (res nil))
           (while (and (setq res (re-search-forward re limit t))



reply via email to

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