Commit f17a228d authored by Alexandre Julliard's avatar Alexandre Julliard

unicode: Try harder to reuse subsequences when compressing data arrays.

parent bfeb0a97
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
No preview for this file type
......@@ -1899,27 +1899,33 @@ sub compress_array($$@)
my $def = shift;
my @table = @_;
my $len = @table / $rows;
my @array = (0) x $rows;
my %sequences;
my @array;
my $data = "";
# try to merge table rows
for (my $row = 0; $row < $rows; $row++)
{
my @table_row = map { defined($_) ? $_ : $def; } @table[($row * $len)..($row * $len + $len - 1)];
my $rowtxt = pack "L*", @table_row;
if (defined($sequences{$rowtxt}))
my $rowtxt = pack "U*", map { defined($_) ? $_ : $def; } @table[($row * $len)..(($row + 1) * $len - 1)];
my $pos = index $data, $rowtxt;
if ($pos == -1)
{
# reuse an existing row
$array[$row] = $sequences{$rowtxt};
}
else
{
# create a new row
$sequences{$rowtxt} = $array[$row] = $#array + 1;
push @array, @table_row;
# check if the tail of the data can match the start of the new row
my $first = substr( $rowtxt, 0, 1 );
for (my $i = length($data) - 1; $i > 0; $i--)
{
$pos = index( substr( $data, -$i ), $first );
last if $pos == -1;
$i -= $pos;
next unless substr( $data, -$i ) eq substr( $rowtxt, 0, $i );
substr( $data, -$i ) = "";
last;
}
$pos = length $data;
$data .= $rowtxt;
}
$array[$row] = $rows + $pos;
}
return @array;
return @array, unpack "U*", $data;
}
################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment