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

ext/B/B.xs

index 74d15fb..27e6d30 100644 (file)
@@ -1600,10 +1600,6 @@ REGEX(sv)
 
 MODULE = B     PACKAGE = B::PV         PREFIX = Sv
 
 
 MODULE = B     PACKAGE = B::PV         PREFIX = Sv
 
-char*
-SvPVX(sv)
-       B::PV   sv
-
 B::SV
 SvRV(sv)
         B::PV   sv
 B::SV
 SvRV(sv)
         B::PV   sv
@@ -1620,12 +1616,17 @@ SvRV(sv)
 void
 SvPV(sv)
        B::PV   sv
 void
 SvPV(sv)
        B::PV   sv
+    ALIAS:
+       PVX = 1
     PREINIT:
        const char *p;
        STRLEN len = 0;
        U32 utf8 = 0;
     CODE:
     PREINIT:
        const char *p;
        STRLEN len = 0;
        U32 utf8 = 0;
     CODE:
-        if( SvPOK(sv) ) {
+       if (ix) {
+           p = SvPVX(sv);
+           len = strlen(p);
+       } else if (SvPOK(sv)) {
            len = SvCUR(sv);
            p = SvPVX_const(sv);
            utf8 = SvUTF8(sv);
            len = SvCUR(sv);
            p = SvPVX_const(sv);
            utf8 = SvUTF8(sv);