diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-11-24 23:11:57 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-11-24 23:24:03 -0800 |
commit | 237da80732005e84a2def6552964d928f0fc014f (patch) | |
tree | eff19b40becbb71755a55f5ddae7faa4faef2481 /mg_raw.h | |
parent | e66ad3503cde2847fa749cda083ec75dea5c7343 (diff) | |
download | perl-237da80732005e84a2def6552964d928f0fc014f.tar.gz |
Reënable qr caching for (??{}) retval where possible
When a scalar is returned from (??{...}) inside a regexp, it gets com-
piled into a regexp if it is not one already. Then the regexp is sup-
posed to be cached on that scalar (in magic), so that the same scalar
returned again will not require another compilation.
Commit e4bfbed39b disabled caching except on references to overloaded
objects. But in that one case the caching caused erroneous behaviour,
which was just fixed by 636209429f and this commit’s parent, effect-
ively disabling the cache altogether.
The cache is disabled because it does not apply to TEMP variables
(those about to be freed anyway, for which caching would be a waste
of CPU), and all non-overloaded non-qr thingies get copied into
new mortal (TEMP) scalars (as of e4bfbed39b) before reaching the
caching code.
This commit skips the copy if the return value is already a non-magi-
cal string or number. It also allows the caching to happen on con-
stants, which has never been permitted before. (There is actually no
reason for disallowing qr magic on read-only variables.)
Diffstat (limited to 'mg_raw.h')
-rw-r--r-- | mg_raw.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -60,7 +60,7 @@ "/* tiedelem 'p' Tied array or hash element */" }, { 'q', "want_vtbl_packelem", "/* tiedscalar 'q' Tied scalar or handle */" }, - { 'r', "want_vtbl_regexp | PERL_MAGIC_VALUE_MAGIC", + { 'r', "want_vtbl_regexp | PERL_MAGIC_READONLY_ACCEPTABLE | PERL_MAGIC_VALUE_MAGIC", "/* qr 'r' precompiled qr// regex */" }, { 'S', "magic_vtable_max", "/* sig 'S' %SIG hash */" }, |