sv.c: Remove redundant sv_force_normal calls from sv_2[iun]v
authorFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 06:42:09 +0000 (23:42 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 09:04:57 +0000 (02:04 -0700)
The previous commit made it possible to nummify a string whose SvLEN
is 0.  So we don’t need to run shared hash key scalars through
sv_force_normal before nummifying them.  We still need to run COW sca-
lars through sv_force_normal under PERL_OLD_COPY_ON_WRITE, as it uses
the IVX field for COW bookkeeping.  For simplicity’s sake, I’m not
bothering to distinguish shared hash keys scalars from other COW sca-
lars under PERL_OLD_COPY_ON_WRITE.

sv.c

diff --git a/sv.c b/sv.c
index 66eae2c..182bcec 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2314,9 +2314,11 @@ Perl_sv_2iv_flags(pTHX_ register SV *const sv, const I32 flags)
     }
 
     if (SvTHINKFIRST(sv)) {
+#ifdef PERL_OLD_COPY_ON_WRITE
        if (SvIsCOW(sv)) {
            sv_force_normal_flags(sv, 0);
        }
+#endif
        if (SvREADONLY(sv) && !SvOK(sv)) {
            if (ckWARN(WARN_UNINITIALIZED))
                report_uninit(sv);
@@ -2399,9 +2401,11 @@ Perl_sv_2uv_flags(pTHX_ register SV *const sv, const I32 flags)
     }
 
     if (SvTHINKFIRST(sv)) {
+#ifdef PERL_OLD_COPY_ON_WRITE
        if (SvIsCOW(sv)) {
            sv_force_normal_flags(sv, 0);
        }
+#endif
        if (SvREADONLY(sv) && !SvOK(sv)) {
            if (ckWARN(WARN_UNINITIALIZED))
                report_uninit(sv);
@@ -2475,9 +2479,11 @@ Perl_sv_2nv_flags(pTHX_ register SV *const sv, const I32 flags)
            }
            return PTR2NV(SvRV(sv));
        }
+#ifdef PERL_OLD_COPY_ON_WRITE
        if (SvIsCOW(sv)) {
            sv_force_normal_flags(sv, 0);
        }
+#endif
        if (SvREADONLY(sv) && !SvOK(sv)) {
            if (ckWARN(WARN_UNINITIALIZED))
                report_uninit(sv);