This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove special string handling from sv.c:sv_reset
authorFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 20:14:03 +0000 (13:14 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 20:14:03 +0000 (13:14 -0700)
Once upon a time, "" and undef were equivalent, and str_reset (as it
was called) would turn a scalar into an empty string.

Since commit 79072805bf6 (perl 5.0 alpha 2), sv_reset has set sca-
lars to undef.

Setting SvCUR to 0 and *SvPVX to '\0' (converted from str->cur and
str->ptr[0] by the same commit 79072805bf6) has not been neces-
sary since.

sv.c

diff --git a/sv.c b/sv.c
index 8765397..3ccac3f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -9151,9 +9151,6 @@ Perl_sv_resetpvn(pTHX_ const char *s, STRLEN len, HV * const stash)
                    SV_CHECK_THINKFIRST_COW_DROP(sv);
                    SvOK_off(sv);
                    if (SvTYPE(sv) >= SVt_PV) {
-                       SvCUR_set(sv, 0);
-                       if (SvPVX_const(sv) != NULL)
-                           *SvPVX(sv) = '\0';
                        SvTAINT(sv);
                    }
                }