[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Any performance comparison/guide of/for Emacs regex?
From: |
Tim X |
Subject: |
Re: Any performance comparison/guide of/for Emacs regex? |
Date: |
Wed, 19 Jan 2011 08:27:56 +1100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Oleksandr Gavenko <gavenko@bifit.com.ua> writes:
> Any performance comparison/guide of/for Emacs regex?
>
> Which construction use to get more performance?
>
>
None that I'm aware of.
With respect to performance, just follow the golden rule and make sure
your regexp is anchored in some way.
Many regexp implementations use a backtrackin form of regexp. If you
don't anchor your regexp in some way, the amount of work it does in
trying to find a match before giving up can grow very fast and can even
give the impression the system is locked up.
Common anchoring techniques include using ^ and $ to anchor your regexp
to the start/end of a line and avoiding regexp with 'match everything'
type wildcards at the start and end. If you know your regexp needs to
match a specific sequence, include it and be as specific as possible.
Use the correct meta characters such as ?, *, + etc. Take advantage of
shy groups and non-greedy forms when they make sense. In general, be as
precise as you can.
Tim
--
tcross (at) rapttech dot com dot au