This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Removed cpan/File-CheckTree
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index 727e283..ba09305 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -884,7 +884,7 @@ static const struct body_details bodies_by_type[] = {
     /* The bind placeholder pretends to be an RV for now.
        Also it's marked as "can't upgrade" to stop anyone using it before it's
        implemented.  */
-    { 0, 0, 0, SVt_BIND, TRUE, NONV, NOARENA, 0 },
+    { 0, 0, 0, SVt_DUMMY, TRUE, NONV, NOARENA, 0 },
 
     /* IVs are in the head, so the allocation size is 0.  */
     { 0,
@@ -1246,12 +1246,12 @@ Perl_sv_upgrade(pTHX_ SV *const sv, svtype new_type)
        assert(!SvPAD_TYPED(sv));
        break;
     default:
-       if (old_type_details->cant_upgrade)
+       if (UNLIKELY(old_type_details->cant_upgrade))
            Perl_croak(aTHX_ "Can't upgrade %s (%" UVuf ") to %" UVuf,
                       sv_reftype(sv, 0), (UV) old_type, (UV) new_type);
     }
 
-    if (old_type > new_type)
+    if (UNLIKELY(old_type > new_type))
        Perl_croak(aTHX_ "sv_upgrade from type %d down to type %d",
                (int)old_type, (int)new_type);
 
@@ -1386,7 +1386,7 @@ Perl_sv_upgrade(pTHX_ SV *const sv, svtype new_type)
            SvNV_set(sv, 0);
 #endif
 
-       if (new_type == SVt_PVIO) {
+       if (UNLIKELY(new_type == SVt_PVIO)) {
            IO * const io = MUTABLE_IO(sv);
            GV *iogv = gv_fetchpvs("IO::File::", GV_ADD, SVt_PVHV);
 
@@ -1399,7 +1399,7 @@ Perl_sv_upgrade(pTHX_ SV *const sv, svtype new_type)
            SvSTASH_set(io, MUTABLE_HV(SvREFCNT_inc(GvHV(iogv))));
            IoPAGE_LEN(sv) = 60;
        }
-       if (new_type == SVt_REGEXP)
+       if (UNLIKELY(new_type == SVt_REGEXP))
            sv->sv_u.svu_rx = (regexp *)new_body;
        else if (old_type < SVt_PV) {
            /* referant will be NULL unless the old type was SVt_IV emulating
@@ -4073,7 +4073,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, SV* sstr, const I32 flags)
        }
        break;
 
-       /* case SVt_BIND: */
+       /* case SVt_DUMMY: */
     case SVt_PVLV:
     case SVt_PVGV:
     case SVt_PVMG:
@@ -6136,7 +6136,7 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
                SvREFCNT_dec(SvSTASH(sv));
        }
        switch (type) {
-           /* case SVt_BIND: */
+           /* case SVt_DUMMY: */
        case SVt_PVIO:
            if (IoIFP(sv) &&
                IoIFP(sv) != PerlIO_stdin() &&
@@ -6257,6 +6257,8 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
                PL_last_in_gv = NULL;
            else if ((const GV *)sv == PL_statgv)
                PL_statgv = NULL;
+            else if ((const GV *)sv == PL_stderrgv)
+                PL_stderrgv = NULL;
        case SVt_PVMG:
        case SVt_PVNV:
        case SVt_PVIV:
@@ -6511,8 +6513,6 @@ S_curse(pTHX_ SV * const sv, const bool check_refcnt) {
        SvOBJECT_off(sv);       /* Curse the object. */
        SvSTASH_set(sv,0);      /* SvREFCNT_dec may try to read this */
        SvREFCNT_dec(stash); /* possibly of changed persuasion */
-       if (SvTYPE(sv) != SVt_PVIO)
-           --PL_sv_objcount;/* XXX Might want something more general */
     }
     return TRUE;
 }
@@ -9406,7 +9406,7 @@ Perl_sv_reftype(pTHX_ const SV *const sv, const int ob)
                                    ? "GLOB" : "SCALAR");
        case SVt_PVFM:          return "FORMAT";
        case SVt_PVIO:          return "IO";
-       case SVt_BIND:          return "BIND";
+       case SVt_DUMMY:         return "DUMMY";
        case SVt_REGEXP:        return "REGEXP";
        default:                return "UNKNOWN";
        }
@@ -9692,14 +9692,10 @@ Perl_sv_bless(pTHX_ SV *const sv, HV *const stash)
        if (SvREADONLY(tmpRef) && !SvIsCOW(tmpRef))
            Perl_croak_no_modify();
        if (SvOBJECT(tmpRef)) {
-           if (SvTYPE(tmpRef) != SVt_PVIO)
-               --PL_sv_objcount;
            SvREFCNT_dec(SvSTASH(tmpRef));
        }
     }
     SvOBJECT_on(tmpRef);
-    if (SvTYPE(tmpRef) != SVt_PVIO)
-       ++PL_sv_objcount;
     SvUPGRADE(tmpRef, SVt_PVMG);
     SvSTASH_set(tmpRef, MUTABLE_HV(SvREFCNT_inc_simple(stash)));
 
@@ -11329,13 +11325,13 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 
        have = esignlen + zeros + elen;
        if (have < zeros)
-           croak_memory_wrap();
+           Perl_croak_memory_wrap();
 
        need = (have > width ? have : width);
        gap = need - have;
 
        if (need >= (((STRLEN)~0) - SvCUR(sv) - dotstrlen - 1))
-           croak_memory_wrap();
+           Perl_croak_memory_wrap();
        SvGROW(sv, SvCUR(sv) + need + dotstrlen + 1);
        p = SvEND(sv);
        if (esignlen && fill == '0') {
@@ -12137,7 +12133,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
        SvANY(dstr)     = new_XNV();
        SvNV_set(dstr, SvNVX(sstr));
        break;
-       /* case SVt_BIND: */
+       /* case SVt_DUMMY: */
     default:
        {
            /* These are all the types that need complex bodies allocating.  */
@@ -12435,9 +12431,6 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
        }
     }
 
-    if (SvOBJECT(dstr) && SvTYPE(dstr) != SVt_PVIO)
-       ++PL_sv_objcount;
-
     return dstr;
  }
 
@@ -13134,7 +13127,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     Zero(&PL_body_roots, 1, PL_body_roots);
     
     PL_sv_count                = 0;
-    PL_sv_objcount     = 0;
     PL_sv_root         = NULL;
     PL_sv_arenaroot    = NULL;