in reply to Performance penalty of using qr//
The problem is actually to do with (potential) captures. Currently, capture information (the information that is used to create the values of $1 et al when accessed) is stored as part of the regex object. This model doesn't work well when the same regex can be used in multiple places. This code:
outputs:$r = qr/(.)/; "a" =~ $r; print "$1\n"; { "b" =~ $r; print "$1\n"; } print "$1\n";
Thus a single regex object has to be associated with multiple capture sets, which change as scopes are exited.a b a
The current workaround for this is to duplicate the qr// object each time it's executed, which is sub-optimal. Unfortunately fixing this properly is non-trivial.
Dave.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Performance penalty of using qr//
by Anonymous Monk on Dec 21, 2017 at 13:22 UTC | |
by dave_the_m (Monsignor) on Dec 21, 2017 at 13:29 UTC | |
by Eily (Monsignor) on Dec 21, 2017 at 14:56 UTC | |
by dave_the_m (Monsignor) on Dec 21, 2017 at 20:01 UTC | |
by vr (Curate) on Dec 22, 2017 at 19:26 UTC |
In Section
Seekers of Perl Wisdom