in reply to Re: Optimize a pluggable regex matching mechanism (/o practically deprecated)
in thread Optimize a pluggable regex matching mechanism
Perl's checking a regex-cache to see if it has already compiled the pattern.
No, the cache is not nearly so general. Each op simply remembers the last pattern it compiled.
>perl -Mre=debug -e"/$_/ for qw( a a b a )" 2>&1 | find "Compiling" Compiling REx "a" Compiling REx "b" Compiling REx "a"
>perl -Mre=debug -e"/a/; /a/;" 2>&1 | find "Compiling" Compiling REx "a" Compiling REx "a"
Nothing's stopping you from making your own such cache, though.
my $compiled_pat = $compiled_pats{$pat} ||= qr/$pat/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Optimize a pluggable regex matching mechanism (/o practically deprecated)
by LanX (Saint) on Nov 10, 2009 at 16:52 UTC |