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: Stefan Monnier
Subject: Re: Any performance comparison/guide of/for Emacs regex?
Date: Tue, 18 Jan 2011 13:29:35 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> 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.

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.


        Stefan


reply via email to

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