diff options
author | Nicholas Clark <nick@ccl4.org> | 2002-02-22 14:01:25 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-02-22 13:47:08 +0000 |
commit | a8373f85cdf8db0f23cb2c640d18875deb1b4d44 (patch) | |
tree | aa6d2d5e2cd1967ff0648da0c9a535e38baf2da4 /ext/Encode | |
parent | bf313bd694adee5e6534146ff2fcfde9dae51e06 (diff) | |
download | perl-a8373f85cdf8db0f23cb2c640d18875deb1b4d44.tar.gz |
Re: [PATCH++] Re: [PATCH] go faster for Encode's compile
Message-ID: <20020222140123.GD358@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@14831
Diffstat (limited to 'ext/Encode')
-rwxr-xr-x | ext/Encode/compile | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/ext/Encode/compile b/ext/Encode/compile index b5f827d1f9..44104ef79c 100755 --- a/ext/Encode/compile +++ b/ext/Encode/compile @@ -468,7 +468,7 @@ sub compile_enc } else { - $seen{$uch} = $page << 16 | $ch; + $seen{$uch} = $page << 8 | $ch; } # Passing 2 extra args each time is 3.6% slower! # Even with having to add $fallback ||= 0 later @@ -729,35 +729,34 @@ sub char_names sub output_ucm_page { - my ($cmap,$a,$t,$pre) = @_; - # warn sprintf("Page %x\n",$pre); - foreach my $b (sort keys %$t) - { - die "Changed - fix me for new structure"; - my ($s,$e,$out,$n,$end,$l,$fb) = @{$t->{$b}}; - die "oops $s $e" unless $s eq $e; - my $u = ord($s); - if ($n != $a && $n != $t) - { - output_ucm_page($cmap,$a,$n,(($pre|($u &0x3F)) << 6)&0xFFFF); - } - elsif (length($out)) - { - if ($pre) - { - $u = $pre|($u &0x3f); - } - my $s = sprintf "<U%04X> ",$u; - foreach my $c (split(//,$out)) - { - $s .= sprintf "\\x%02X",ord($c); + my ($cmap,$a,$t,$pre) = @_; + # warn sprintf("Page %x\n",$pre); + my $raw = $t->{Raw}; + foreach my $key (sort keys %$raw) { + # RAW_NEXT => 0, + # RAW_IN_LEN => 1, + # RAW_OUT_BYTES => 2, + # RAW_FALLBACK => 3, + my ($next, $in_len, $out_bytes, $fallback) = @{$raw->{$key}}; + my $u = ord $key; + $fallback ||= 0; + + if ($next != $a && $next != $t) { + output_ucm_page($cmap,$a,$next,(($pre|($u &0x3F)) << 6)&0xFFFF); + } elsif (length $out_bytes) { + if ($pre) { + $u = $pre|($u &0x3f); } - $s .= sprintf " |%d # %s\n",($fb ? 1 : 0),$uname[$u]; - push(@$cmap,$s); - } - else - { - warn join(',',@{$t->{$b}},$a,$t); + my $s = sprintf "<U%04X> ",$u; + #foreach my $c (split(//,$out_bytes)) { + # $s .= sprintf "\\x%02X",ord($c); + #} + # 9.5% faster changing that lloop to this: + $s .= sprintf +("\\x%02X" x length $out_bytes), unpack "C*", $out_bytes; + $s .= sprintf " |%d # %s\n",($fallback ? 1 : 0),$uname[$u]; + push(@$cmap,$s); + } else { + warn join(',',$u, @{$raw->{$key}},$a,$t); } } } |