diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-11-07 15:19:15 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-11-08 07:55:09 +0000 |
commit | a804b0fe1a329489a361df0373bc50d659d84c68 (patch) | |
tree | 8f39d43139c903632369cb8bd3c2d14486d142c3 /ext/B | |
parent | 81e413dd293ca530aa3b6f9cd587b94ada3bd0a0 (diff) | |
download | perl-a804b0fe1a329489a361df0373bc50d659d84c68.tar.gz |
Refactor B::PV::PV to use newSVpvn_flags() for both arms of the if.
newSVpvn_flags(NULL, whatever, SVs_TEMP) is equivalent to sv_newmortal().
Diffstat (limited to 'ext/B')
-rw-r--r-- | ext/B/B.xs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/B/B.xs b/ext/B/B.xs index fa72c9ee47..74d15fbdbc 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1620,10 +1620,15 @@ SvRV(sv) void SvPV(sv) B::PV sv + PREINIT: + const char *p; + STRLEN len = 0; + U32 utf8 = 0; CODE: if( SvPOK(sv) ) { - STRLEN len = SvCUR(sv); - const char *p = SvPVX_const(sv); + len = SvCUR(sv); + p = SvPVX_const(sv); + utf8 = SvUTF8(sv); #if PERL_VERSION < 10 /* Before 5.10 (well 931b58fb28fa5ca7), PAD_COMPNAME_GEN was stored in SvCUR(), which meant we had to attempt this special casing @@ -1634,13 +1639,13 @@ SvPV(sv) len = strlen(p); } #endif - ST(0) = newSVpvn_flags(p, len, SVs_TEMP | SvUTF8(sv)); } else { /* XXX for backward compatibility, but should fail */ /* croak( "argument is not SvPOK" ); */ - ST(0) = sv_newmortal(); + p = NULL; } + ST(0) = newSVpvn_flags(p, len, SVs_TEMP | utf8); # This used to read 257. I think that that was buggy - should have been 258. # (The "\0", the flags byte, and 256 for the table. Not that anything |