diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-30 09:31:47 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-30 12:39:39 -0700 |
commit | 23496c6ea4cd9e3c09a9fe1878f55f241bdc17e5 (patch) | |
tree | 308baee5cf0e50b4fd4b0170aff3f1be4b9b66f2 /proto.h | |
parent | 38552987f01ba3c9fbea08e94b95b439e5ded364 (diff) | |
download | perl-23496c6ea4cd9e3c09a9fe1878f55f241bdc17e5.tar.gz |
Eliminate is_gv_magical_sv
This resolves perl bug #97978.
Many built-in variables, like $], are actually created on the fly
when first accessed. Perl likes to pretend that these variables have
always existed, so it autovivifies the *] glob even in rvalue context
(e.g., defined *{"]"}, close "]").
The list of variables that were autovivified was maintained separ-
ately (in is_gv_magical_sv) from the code that actually creates
them (gv_fetchpvn_flags). ‘Maintained’ is not actually precise: it
*wasn’t* being maintained, and there were new variables that never
got added to is_gv_magical_sv and one deleted variable that was
never removed.
There are only two pieces of code that call is_gv_magical_sv, both in
pp.c: S_rv2gv (called by *{} and also the implicit *{} that functions
like close() provide) and Perl_softrefxv (called by ${}, @{}, %{}).
In both cases, the glob is immediately autovivified if
is_gv_magical_sv returns true.
So this commit eliminates the extra maintenance burden by extirpat-
ing is_gv_magical_sv altogether, and replacing it with a new flag to
gv_fetchpvn_flags, GvADDMG, which will autovivify a glob *if* it’s a
magical one.
It does make defined(*{"frobbly"}) slightly slower, in that it creates
a temporary glob and then frees it when it sees nothing magical has
been done with it. But this case is rare enough it should not matter.
At least I got rid of the bugginess.
Diffstat (limited to 'proto.h')
-rw-r--r-- | proto.h | 6 |
1 files changed, 0 insertions, 6 deletions
@@ -1520,12 +1520,6 @@ PERL_CALLCONV bool Perl_is_ascii_string(const U8 *s, STRLEN len) #define PERL_ARGS_ASSERT_IS_ASCII_STRING \ assert(s) -PERL_CALLCONV bool Perl_is_gv_magical_sv(pTHX_ SV *const name_sv, U32 flags) - __attribute__warn_unused_result__ - __attribute__nonnull__(pTHX_1); -#define PERL_ARGS_ASSERT_IS_GV_MAGICAL_SV \ - assert(name_sv) - PERL_CALLCONV I32 Perl_is_lvalue_sub(pTHX) __attribute__warn_unused_result__; |