Stop toggling the FAKE flag for stringified GVs
authorFather Chrysostomos <sprout@cpan.org>
Sun, 6 Nov 2011 09:40:57 +0000 (01:40 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 6 Nov 2011 10:10:05 +0000 (02:10 -0800)
Back in the old days, when GVs had magic attached to them, get-magic
used to stringify the glob and assign the string to the PV field.  It
was triggered in mg.c like this:

    gv_efullname3(sv,((GV*)sv), "*");

Because sv was both the glob being read *and* the string being
assigned to, the stringification would call set-magic on the glob and
flatten the glob into a string.  Or something like that.

That is not necessary any more.

sv.c

diff --git a/sv.c b/sv.c
index 84dabae..00caa2f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -1813,16 +1813,11 @@ Perl_looks_like_number(pTHX_ SV *const sv)
 STATIC bool
 S_glob_2number(pTHX_ GV * const gv)
 {
-    const U32 wasfake = SvFLAGS(gv) & SVf_FAKE;
     SV *const buffer = sv_newmortal();
 
     PERL_ARGS_ASSERT_GLOB_2NUMBER;
 
-    /* FAKE globs can get coerced, so need to turn this off temporarily if it
-       is on.  */
-    SvFAKE_off(gv);
     gv_efullname3(buffer, gv, "*");
-    SvFLAGS(gv) |= wasfake;
 
     /* We know that all GVs stringify to something that is not-a-number,
        so no need to test that.  */
@@ -2949,14 +2944,9 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN *const lp, const I32 flags
     else {
        if (isGV_with_GP(sv)) {
            GV *const gv = MUTABLE_GV(sv);
-           const U32 wasfake = SvFLAGS(gv) & SVf_FAKE;
            SV *const buffer = sv_newmortal();
 
-           /* FAKE globs can get coerced, so need to turn this off temporarily
-              if it is on.  */
-           SvFAKE_off(gv);
            gv_efullname3(buffer, gv, "*");
-           SvFLAGS(gv) |= wasfake;
 
            assert(SvPOK(buffer));
            if (lp) {
@@ -4372,15 +4362,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV* sstr, const I32 flags)
     }
     else {
        if (isGV_with_GP(sstr)) {
-           /* This stringification rule for globs is spread in 3 places.
-              This feels bad. FIXME.  */
-           const U32 wasfake = sflags & SVf_FAKE;
-
-           /* FAKE globs can get coerced, so need to turn this off
-              temporarily if it is on.  */
-           SvFAKE_off(sstr);
            gv_efullname3(dstr, MUTABLE_GV(sstr), "*");
-           SvFLAGS(sstr) |= wasfake;
        }
        else
            (void)SvOK_off(dstr);