Create &B::{IV,PV}::as_string using typeglob assignment rather than goto &
authorNicholas Clark <nick@ccl4.org>
Thu, 4 Nov 2010 14:21:05 +0000 (14:21 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 4 Nov 2010 14:21:05 +0000 (14:21 +0000)
Typeglob assignment avoids compiler work creating the optree for a second
subroutine, and runtime work executing that optree.

ext/B/B.pm

index 4cd5545..587b809 100644 (file)
@@ -105,8 +105,8 @@ sub B::IV::int_value {
 }
 
 sub B::NULL::as_string() {""}
-sub B::IV::as_string()   {goto &B::IV::int_value}
-sub B::PV::as_string()   {goto &B::PV::PV}
+*B::IV::as_string = \&B::IV::int_value;
+*B::PV::as_string = \&B::PV::PV;
 
 my $debug;
 my $op_count = 0;