[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18013: 24.3.92; looking-back "[^\n]" taking a lot of time in large b
bug#18013: 24.3.92; looking-back "[^\n]" taking a lot of time in large buffers (was: Infloop in re_search_2)
Mon, 14 Jul 2014 13:12:34 +0200
Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux)
Andreas Schwab <address@hidden> writes:
> Nicolas Richard <address@hidden> writes:
>> I'll admit that (looking-back "[^\n]") is not exactly the canonical way
>> to test for (not (bolp)), but should it make an infloop ? I can't
>> reproduce though.
> I don't think it infloops, it just takes a very long time. Since this
> is running in a process filter interrupts are disabled, so you have to
> be extra careful with what you do here.
It seems you were totally right, thanks ! Here's a repro test case :
# pick up a big file or make one :
$ yes | dd bs=1MB iflag=fullblock count=50 > foobartest
50+0 enregistrements lus
50+0 enregistrements écrits
50000000 octets (50 MB) copiés, 0,853576 s, 58,6 MB/s
# open it in an emacs buffer and try looking-back :
$ time emacs --batch -Q --eval '(with-temp-buffer (insert-file-contents
"foobartest") (goto-char (point-max)) (princ "Looking back...") (looking-back
"[^\n]") (princ "done!") (terpri))'
As you see it takes more than 8 seconds on my system, most of that time
is spent looking-back (inserting the file is quick).
(looking-back "[^\n]") is bad code, so I totally deserve this. Still, is
it possible to make the search smarter when the match is supposed to be
"anchored" at point ? Otherwise let's just close this bug.