Re: Speed comparison of regex versus index, lc, and / /i
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Sat, 31 May 2008 04:12:54 +0100
Quoth "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>:
Changing this to
while ( $text =~ /\Q$ss\E/og ) {
makes regex_find faster by about 1%.
my $rx = qr/\Q$ss/;
...
while ($text =~ /$rx/g) {
is both clearer and safer. If the program is modified so that $ss is
actually variable (say, the whole thing is made into a sub) then /o
would cause it to fail in ways that are rather hard to diagnose.
Note that m// will only use the precompiled form of the qr// if the
$rx is the only thing in the match. Something like /^$rx/ or
/$rx1|$rx2/ or even / $rx/x will cause the regex to be recompiled
every time all over again.
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@xxxxxxxxxxxx
.
- Follow-Ups:
- Re: Speed comparison of regex versus index, lc, and / /i
- From: Abigail
- Re: Speed comparison of regex versus index, lc, and / /i
- References:
- Speed comparison of regex versus index, lc, and / /i
- From: Ben Bullock
- Re: Speed comparison of regex versus index, lc, and / /i
- From: Ben Bullock
- Re: Speed comparison of regex versus index, lc, and / /i
- From: A. Sinan Unur
- Re: Speed comparison of regex versus index, lc, and / /i
- From: A. Sinan Unur
- Speed comparison of regex versus index, lc, and / /i
- Prev by Date: Re: Need help with a simple (I think) Perl script
- Next by Date: Re: Speed comparison of regex versus index, lc, and / /i
- Previous by thread: Re: Speed comparison of regex versus index, lc, and / /i
- Next by thread: Re: Speed comparison of regex versus index, lc, and / /i
- Index(es):
Relevant Pages
|
|