[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant
From: |
npostavs |
Subject: |
bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant |
Date: |
Tue, 14 May 2019 10:34:55 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (windows-nt) |
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>> Hmm, current thing-at-point-looking-at might be slow with large
>> buffers. The slightly modified test should reveal it:
>>
>> (ert-deftest thing-at-point-looking-at-2 ()
>> (with-temp-buffer
>> (insert "1abcd 222abcd")
>> (dotimes (_ 99999) (insert " asdf "))
>> (goto-char (point-min))
>> (search-forward "2ab")
>> (should (thing-at-point-looking-at "2abcd"))
Yes, in this case, since the loop over looking-at only needs to iterate
twice, so it will be faster. But what about when there is no match?
E.g.,
(with-temp-buffer
(dotimes (_ 99999) (insert " asdf "))
(goto-char (point-max))
(list :ar-regexp-atpt (benchmark-run (ar-regexp-atpt "foo"))
:thing-at-point-looking-at (benchmark-run (thing-at-point-looking-at
"foo"))))
> Another fix, as a bug showed up when testing (ar-regexp-atpt "[a-z]+"):
>
> (defun ar-regexp-atpt (regexp)
> "Return t if REGEXP matches at or before point, nil otherwise.
>
> Changes match-data"
> (save-excursion
> (if (looking-at regexp)
> (while
> (and (not (bobp))
> (or (progn (backward-char) (looking-at regexp))
> (forward-char 1))))
> (while (not (or (bobp) (backward-char) (looking-at regexp))))
> (ar-regexp-atpt regexp))
What's this recursive call for? It triggers (error "Lisp nesting
exceeds ‘max-lisp-eval-depth’") in the benchmark above.
> (looking-at regexp)))
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Andreas Röhler, 2019/05/13
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Noam Postavsky, 2019/05/13
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Andreas Röhler, 2019/05/13
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, npostavs, 2019/05/13
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Andreas Röhler, 2019/05/14
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Andreas Röhler, 2019/05/14
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant,
npostavs <=
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Andreas Röhler, 2019/05/15
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Andreas Röhler, 2019/05/15
- bug#35708: [27.0.50]: thingatpt.el, thing-at-point-looking-at redundant, Noam Postavsky, 2019/05/20