This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge the implementation of B::BM::TABLE with B::PV::{PV,PVX,PVBM} using ALIAS.
authorNicholas Clark <nick@ccl4.org>
Sun, 7 Nov 2010 17:33:42 +0000 (17:33 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 8 Nov 2010 07:55:10 +0000 (07:55 +0000)
On this platform, this reduces the object code size by about .5K.

ext/B/B.xs

index 3841655..9dd6d06 100644 (file)
@@ -1619,12 +1619,18 @@ PV(sv)
     ALIAS:
        PVX = 1
        PVBM = 2
+       B::BM::TABLE = 3
     PREINIT:
        const char *p;
        STRLEN len = 0;
        U32 utf8 = 0;
     CODE:
-       if (ix == 2) {
+       if (ix == 3) {
+           p = SvPV(sv, len);
+           /* Boyer-Moore table is just after string and its safety-margin \0 */
+           p += len + PERL_FBM_TABLE_OFFSET;
+           len = 256;
+       } else 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.  */
@@ -1733,18 +1739,6 @@ MOREMAGIC(mg)
            break;
        }
 
-MODULE = B     PACKAGE = B::BM
-
-void
-TABLE(sv)
-       B::BM   sv
-       STRLEN  len = NO_INIT
-       char *  str = NO_INIT
-    CODE:
-       str = SvPV(sv, len);
-       /* Boyer-Moore table is just after string and its safety-margin \0 */
-       ST(0) = newSVpvn_flags(str + len + PERL_FBM_TABLE_OFFSET, 256, SVs_TEMP);
-
 MODULE = B     PACKAGE = B::GV         PREFIX = Gv
 
 void