This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
It appears that it's trivially easy to alias opcode functions in
authorNicholas Clark <nick@ccl4.org>
Mon, 31 Oct 2005 15:52:50 +0000 (15:52 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 31 Oct 2005 15:52:50 +0000 (15:52 +0000)
the opcode table. We should be able to get both a speed and size
saving here. Time will tell how much.

p4raw-id: //depot/perl@25929

opcode.h
opcode.pl

index e7af19b..d52088a 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -894,8 +894,8 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        MEMBER_TO_FPTR(Perl_pp_aelem),
        MEMBER_TO_FPTR(Perl_pp_aslice),
        MEMBER_TO_FPTR(Perl_pp_each),
-       MEMBER_TO_FPTR(Perl_pp_values),
-       MEMBER_TO_FPTR(Perl_pp_keys),
+       MEMBER_TO_FPTR(Perl_do_kv),
+       MEMBER_TO_FPTR(Perl_do_kv),
        MEMBER_TO_FPTR(Perl_pp_delete),
        MEMBER_TO_FPTR(Perl_pp_exists),
        MEMBER_TO_FPTR(Perl_pp_rv2hv),
index 571fa14..a3284da 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -33,6 +33,19 @@ while (<DATA>) {
     $args{$key} = $args;
 }
 
+# Set up aliases
+
+my %alias;
+
+# Format is "this function" => "does these op names"
+my @raw_alias = (
+                Perl_do_kv => 'keys values',
+               );
+
+while (my ($func, $names) = splice @raw_alias, 0, 2) {
+    $alias{$_} = $func foreach split ' ', $names;
+}
+
 # Emit defines.
 
 $i = 0;
@@ -170,7 +183,8 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
 END
 
 for (@ops) {
-    print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n" unless $_ eq "custom";
+    my $name = $alias{$_} || "Perl_pp_$_";
+    print "\tMEMBER_TO_FPTR($name),\n" unless $_ eq "custom";
 }
 
 print <<END;