help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any performance comparison/guide of/for Emacs regex?


From: Oleksandr Gavenko
Subject: Re: Any performance comparison/guide of/for Emacs regex?
Date: Tue, 18 Jan 2011 23:48:47 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6

On 2011-01-18 20:29, Stefan Monnier wrote:
Any performance comparison/guide of/for Emacs regex?

Not really.  What you need to know is that Emacs's regexp engine is
based on backtracking, so things like .*\\(.*\\).* is insanely
inefficient and will make you think Emacs is frozen.

Thanks for answer!

How about if \\(.*\\) used to enclose a set of `\|'
alternatives or for referencing in font-lock expressions?

Generally, you'll prefer to use regexps that don't require backtracking.
E.g. [^(\n]*( works much better than .*( since when encountering an open
parenthesis, the matcher will know for sure that it has to leave the *
loop, rather than having to try both cases in sequence.

I get basic understand but read more about backtracking
in regex engine some later. Thanks.

--
Best regards!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]