GNU bug report logs -
#39598
26.3; Emacs is extremely unresponsive on a trivial python file
Previous Next
Reported by: Ivan Oreshnikov <oreshnikov.ivan <at> gmail.com>
Date: Fri, 14 Feb 2020 10:50:01 UTC
Severity: normal
Tags: fixed
Found in version 26.3
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Ivan Oreshnikov <oreshnikov.ivan <at> gmail.com>
>> Date: Fri, 14 Feb 2020 17:31:48 +0100
>> Cc: 39598 <at> debbugs.gnu.org
>>
>> Ok, here's the full expansion of the relevant part of the profiler report:
>
> Looks like this part of python-nav--forward-sexp needs some
> optimizations:
Actually, it seems the main problem is a bit higher up.
python-info-docstring-p calls python-nav-backward-sexp repeatedly, until
it hits a non-string sexp. Even though it's only checking for two sexp
strings.
(let ((counter 1)
...
;; Allow up to two consecutive docstrings only.
(>=
2
(let (last-backward-sexp-point)
(while (save-excursion
(python-nav-backward-sexp)
(setq backward-sexp-point (point))
(and (= indentation (current-indentation))
...
(looking-at-p
(concat "[uU]?[rR]?"
(python-rx string-delimiter)))))
;; Previous sexp was a string, restore point.
(goto-char backward-sexp-point)
(cl-incf counter))
counter)))
So any repetitions of the while loop after the second one are useless.
The patch (generated with --ignore-all-space) below fixes it:
--- c/lisp/progmodes/python.el
+++ i/lisp/progmodes/python.el
@@ -5135,7 +5135,8 @@ python-info-docstring-p
(>=
2
(let (last-backward-sexp-point)
- (while (save-excursion
+ (while (and (<= counter 2)
+ (save-excursion
(python-nav-backward-sexp)
(setq backward-sexp-point (point))
(and (= indentation (current-indentation))
@@ -5149,7 +5150,7 @@ python-info-docstring-p
backward-sexp-point))
(looking-at-p
(concat "[uU]?[rR]?"
- (python-rx string-delimiter)))))
+ (python-rx string-delimiter))))))
;; Previous sexp was a string, restore point.
(goto-char backward-sexp-point)
(cl-incf counter))
This bug report was last modified 4 years and 302 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.