* bug#6640: 23.2; Why is this regexp search taking so long? (and will it end?)
[not found] <yvzgk4own4ym.fsf@cadilhac.name>
@ 2016-03-06 4:12 ` Ryan Rix
2016-06-10 21:13 ` Noam Postavsky
1 sibling, 0 replies; 2+ messages in thread
From: Ryan Rix @ 2016-03-06 4:12 UTC (permalink / raw)
To: 6640; +Cc: michael
michael@cadilhac.name "(Michaël" Cadilhac) writes:
> - emacs -Q
> - Clear the scratch buffer, and paste:
>
[redact]
>
> (a small input would give quite the same result).
> - M-< C-- C-s ^\([^:]*:[^:]*\)\{9\}
>
> (everything works fine till now)
>
> add an $ to the regexp.
>
> - FEAR the possible endless loop (and the actual unexpected result of
> taking long time).
>
> With an 8 in place of the 9, it takes a long time, but not possibly
> endless.
>
> Thanks!
Hi Michael,
Thanks for reporting this. I can confirm this is still an issue in the
latest emacs-25, commit e51b27ec2ce214ef3d8377a27ee9d857bcc66afc
I will leave it to smarter minds than my own to debug the regex engine,
though.
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#6640: 23.2; Why is this regexp search taking so long? (and will it end?)
[not found] <yvzgk4own4ym.fsf@cadilhac.name>
2016-03-06 4:12 ` bug#6640: 23.2; Why is this regexp search taking so long? (and will it end?) Ryan Rix
@ 2016-06-10 21:13 ` Noam Postavsky
1 sibling, 0 replies; 2+ messages in thread
From: Noam Postavsky @ 2016-06-10 21:13 UTC (permalink / raw)
To: 6640; +Cc: Ryan Rix, michael
I haven't actually debugged the regexp engine, but I believe the
problem is that this regexp contains several repetitions of [^:]*[^:]*
(which becomes apparent if you expand the \{9\}). The regexp engine
isn't smart enough to coalesce them so when the match fails (due to
$), it has to go back and retry with all the possible different
matches to see if it will work that way. There are A^n possible
matches to try, where A is the length of non-colon string in the
buffer, and n is the number of [^:]*[^:]* sequences in the regexp
(which is 8 if \{9\} is used).
A regexp which should match the same thing is ^\([^:]*:\)\{9\}[^:]*
and ^\([^:]*:\)\{9\}[^:]*$ will fail to match anything much faster.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-10 21:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <yvzgk4own4ym.fsf@cadilhac.name>
2016-03-06 4:12 ` bug#6640: 23.2; Why is this regexp search taking so long? (and will it end?) Ryan Rix
2016-06-10 21:13 ` Noam Postavsky
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).