summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2014-06-10 16:07:12 +1000
committerTony Cook <tony@develop-help.com>2014-06-18 10:47:29 +1000
commite0dcdb0a6a47e7be80138333509b94c176bdfbe7 (patch)
tree7f1aa4fe11fce1261917de93468da883a5ac1021 /regen
parentd3532481a36e82cf5b9642b3dfe203a314a17cab (diff)
downloadperl-e0dcdb0a6a47e7be80138333509b94c176bdfbe7.tar.gz
avoid copying the whole map to the stack on each call to get_I8_2_utf()
took run time from 51.6 sec to 41.6 sec get_I8_2_utf() is called 147000 times by cp_2_utfbytes() which typically doesn't use the whole table, so return a reference instead to.
Diffstat (limited to 'regen')
-rw-r--r--regen/charset_translations.pl8
-rw-r--r--regen/ebcdic.pl2
2 files changed, 5 insertions, 5 deletions
diff --git a/regen/charset_translations.pl b/regen/charset_translations.pl
index 92099c7a9b..0ca310ee0e 100644
--- a/regen/charset_translations.pl
+++ b/regen/charset_translations.pl
@@ -163,7 +163,7 @@ sub get_I8_2_utf($) {
}
}
- return @{$I8_TO_NATIVE_UTF8{$charset}};
+ return $I8_TO_NATIVE_UTF8{$charset};
}
{ # Closure
@@ -262,7 +262,7 @@ sub cp_2_utfbytes($$) {
return chr $ebcdic_translations{$charset}[$ucp];
}
- my @I8_2_utf = get_I8_2_utf($charset);
+ my $I8_2_utf = get_I8_2_utf($charset);
my $len = $ucp < 0xA0 ? 1 :
$ucp < 0x400 ? 2 :
@@ -273,11 +273,11 @@ sub cp_2_utfbytes($$) {
my @str;
for (1 .. $len - 1) {
- unshift @str, chr $I8_2_utf[($ucp & 0x1f) | 0xA0];
+ unshift @str, chr $I8_2_utf->[($ucp & 0x1f) | 0xA0];
$ucp >>= 5;
}
- unshift @str, chr $I8_2_utf[($ucp & _UTF_START_MASK($len)) | _UTF_START_MARK($len)];
+ unshift @str, chr $I8_2_utf->[($ucp & _UTF_START_MASK($len)) | _UTF_START_MARK($len)];
return join "", @str;
}
diff --git a/regen/ebcdic.pl b/regen/ebcdic.pl
index 055403ea12..60b74aa0ca 100644
--- a/regen/ebcdic.pl
+++ b/regen/ebcdic.pl
@@ -56,7 +56,7 @@ foreach my $charset (@charsets) {
output_table(\@e2a, "PL_e2a");
}
- my @i82utf = get_I8_2_utf($charset);
+ my @i82utf = @{get_I8_2_utf($charset)};
print $out_fh <<END;
/* (Confusingly named) Index is $charset I8 byte; value is
* $charset UTF-EBCDIC equivalent */