Hello dominic01,
The Camel Book (4th Edition, 2012) has a section on “Time Efficiency” which contains the following (p. 692):
Short-circuit alternation is often faster than the corresponding regex. So:
print if /one-hump/ || /two/;is likely to be faster than:
print if /one-hump|two/;at least for certain values of one-hump and two.
Also, if your regex is more likely to find a space than a punctuation character, test for the space first. Only profiling will show whether these kinds of tweaks make significant improvements, but they’re worth a try.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Improving performance
by Athanasius
in thread Improving performance
by dominic01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |