From: Noam Postavsky <npostavs@users.sourceforge.net>
To: 6640@debbugs.gnu.org
Cc: Ryan Rix <ryan@whatthefuck.computer>, michael@cadilhac.name
Subject: bug#6640: 23.2; Why is this regexp search taking so long? (and will it end?)
Date: Fri, 10 Jun 2016 17:13:16 -0400 [thread overview]
Message-ID: <CAM-tV-9vsH6VMU_Mt0tG_sujVejwrf820pUq+h_BW5rqwXSruw@mail.gmail.com> (raw)
In-Reply-To: <yvzgk4own4ym.fsf@cadilhac.name>
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.
prev parent reply other threads:[~2016-06-10 21:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM-tV-9vsH6VMU_Mt0tG_sujVejwrf820pUq+h_BW5rqwXSruw@mail.gmail.com \
--to=npostavs@users.sourceforge.net \
--cc=6640@debbugs.gnu.org \
--cc=michael@cadilhac.name \
--cc=ryan@whatthefuck.computer \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).