This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
B::GV::is_empty and B::GV::isGV_with_GP can be merged using ALIAS.
authorNicholas Clark <nick@ccl4.org>
Fri, 29 Oct 2010 11:41:10 +0000 (12:41 +0100)
committerNicholas Clark <nick@ccl4.org>
Fri, 29 Oct 2010 11:42:08 +0000 (12:42 +0100)
This saves about 700 bytes on this platform.

ext/B/B.xs
ext/B/t/b.t

index 381d5a9..c0c9a4a 100644 (file)
@@ -1643,22 +1643,20 @@ GvNAME(gv)
 bool
 is_empty(gv)
         B::GV   gv
+    ALIAS:
+       isGV_with_GP = 1
     CODE:
-        RETVAL = GvGP(gv) == Null(GP*);
-    OUTPUT:
-        RETVAL
-
-bool
-isGV_with_GP(gv)
-       B::GV   gv
-    CODE:
+       if (ix) {
 #if PERL_VERSION >= 9
-       RETVAL = isGV_with_GP(gv) ? TRUE : FALSE;
+           RETVAL = isGV_with_GP(gv) ? TRUE : FALSE;
 #else
-       RETVAL = TRUE; /* In 5.8 and earlier they all are.  */
+           RETVAL = TRUE; /* In 5.8 and earlier they all are.  */
 #endif
+       } else {
+            RETVAL = GvGP(gv) == Null(GP*);
+       }
     OUTPUT:
-       RETVAL
+        RETVAL
 
 void*
 GvGP(gv)
index 228daa2..d53ebc7 100644 (file)
@@ -197,6 +197,7 @@ local *gv = *STDOUT;
 my $gv_ref = B::svref_2object(\*gv);
 is(ref $gv_ref, "B::GV", "Test B::GV return from svref_2object");
 ok(! $gv_ref->is_empty(), "Test is_empty()");
+ok($gv_ref->isGV_with_GP(), "Test isGV_with_GP()");
 is($gv_ref->NAME(), "gv", "Test NAME()");
 is($gv_ref->SAFENAME(), "gv", "Test SAFENAME()");
 like($gv_ref->FILE(), qr/b\.t$/, "Testing FILE()");