diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-10-17 15:10:58 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-10-17 15:10:58 +0000 |
commit | d279ab826c469db5d93d3d728fdcf1acd9265665 (patch) | |
tree | addeb0185f58c60c5cfc3f8cecb80ea1c6b27088 /overload.pl | |
parent | 7edb818e3f3ca1bd7fb46554919c8cfd222bd37d (diff) | |
download | perl-d279ab826c469db5d93d3d728fdcf1acd9265665.tar.gz |
Storing the length of all the overloading names saves a strlen() in a
loop in Perl_Gv_AMupdate().
Brought to you by the Campaign for the Elimination of strlen().
p4raw-id: //depot/perl@32124
Diffstat (limited to 'overload.pl')
-rw-r--r-- | overload.pl | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/overload.pl b/overload.pl index 9def29f429..6b1050e685 100644 --- a/overload.pl +++ b/overload.pl @@ -71,15 +71,26 @@ print C <<'EOF'; #define AMG_id2name(id) (PL_AMG_names[id]+1) +const U8 PL_AMG_namelens[NofAMmeth] = { +EOF + +my $last = pop @names; + +print C " $_,\n" foreach map { length $_ } @names; + +my $lastlen = length $last; +print C <<"EOT"; + $lastlen +}; + char * const PL_AMG_names[NofAMmeth] = { /* Names kept in the symbol table. fallback => "()", the rest has "(" prepended. The only other place in perl which knows about this convention is AMG_id2name (used for debugging output and 'nomethod' only), the only other place which has it hardwired is overload.pm. */ -EOF +EOT -my $last = pop @names; print C " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names; print C <<"EOT"; @@ -88,6 +99,7 @@ print C <<"EOT"; EOT close H or die $!; +close C or die $!; __DATA__ # Fallback should be the first |