This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge the implementation of B::PV::PVBM with PVX and PV, using ALIAS.
authorNicholas Clark <nick@ccl4.org>
Sun, 7 Nov 2010 16:47:45 +0000 (16:47 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 8 Nov 2010 07:55:09 +0000 (07:55 +0000)
ext/B/B.xs

index 27e6d30..b67dda6 100644 (file)
@@ -1618,12 +1618,23 @@ SvPV(sv)
        B::PV   sv
     ALIAS:
        PVX = 1
+       PVBM = 2
     PREINIT:
        const char *p;
        STRLEN len = 0;
        U32 utf8 = 0;
     CODE:
-       if (ix) {
+       if (ix == 2) {
+           /* 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 anywhere calls this method.  NWC.  */
+           /* Also, the start pointer has always been SvPVX(sv). Surely it
+              should be SvPVX(sv) + SvCUR(sv)?  The code has faithfully been
+              refactored with this behaviour, since PVBM was added in
+              651aa52ea1faa806.  */
+           p = SvPVX_const(sv);
+           len = SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0);
+       } else if (ix) {
            p = SvPVX(sv);
            len = strlen(p);
        } else if (SvPOK(sv)) {
@@ -1648,17 +1659,6 @@ SvPV(sv)
         }
        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
-# anywhere calls this method.  NWC.
-void
-SvPVBM(sv)
-       B::PV   sv
-    CODE:
-        ST(0) = newSVpvn_flags(SvPVX_const(sv),
-           SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0),
-           SVs_TEMP);
-
 MODULE = B     PACKAGE = B::PVMG       PREFIX = Sv
 
 void