Commit b99b9565 authored by Alexandre Julliard's avatar Alexandre Julliard

usp10: Make the various lookup tables more compact.

parent 704a330a
......@@ -82,7 +82,7 @@ void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT
for (i = 0; i < count; i++)
{
break_class[i] = wine_linebreak_table[wine_linebreak_table[chars[i] >> 8] + (chars[i] & 0xff)];
break_class[i] = get_table_entry( wine_linebreak_table, chars[i] );
break_before[i] = 0;
memset(&la[i],0,sizeof(SCRIPT_LOGATTR));
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1446,7 +1446,7 @@ static void ContextualShape_Arabic(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *p
context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars);
for (i = 0; i < cChars; i++)
context_type[i] = wine_shaping_table[wine_shaping_table[pwcChars[i] >> 8] + (pwcChars[i] & 0xff)];
context_type[i] = get_table_entry( wine_shaping_table, pwcChars[i] );
for (i = 0; i < cChars; i++)
{
......@@ -1543,7 +1543,7 @@ static void ContextualShape_Syriac(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *p
context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars);
for (i = 0; i < cChars; i++)
context_type[i] = wine_shaping_table[wine_shaping_table[pwcChars[i] >> 8] + (pwcChars[i] & 0xff)];
context_type[i] = get_table_entry( wine_shaping_table, pwcChars[i] );
for (i = 0; i < cChars; i++)
{
......@@ -2235,7 +2235,7 @@ static inline int unicode_lex(WCHAR c)
if (c == 0x200C) return lex_ZWNJ;
if (c == 0x00A0) return lex_NBSP;
type = indic_syllabic_table[indic_syllabic_table[c >> 8] + (c & 0xff)];
type = get_table_entry( indic_syllabic_table, c );
if ((type & 0x00ff) != 0x0007) type = type & 0x00ff;
......
......@@ -112,6 +112,11 @@ static inline BOOL is_consonant( int type )
return (type == lex_Ra || type == lex_Consonant);
}
static inline WCHAR get_table_entry( const unsigned short *table, WCHAR ch )
{
return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
}
typedef int (*lexical_function)(WCHAR c);
typedef void (*reorder_function)(LPWSTR pwChar, IndicSyllable *syllable, lexical_function lex);
......
......@@ -1119,7 +1119,7 @@ sub dump_indic($)
print OUTPUT "/* DO NOT EDIT!! */\n\n";
print OUTPUT "#include \"wine/unicode.h\"\n\n";
dump_simple_mapping( "indic_syllabic_table", @indic_table);
dump_two_level_mapping( "indic_syllabic_table", @indic_table);
close OUTPUT;
save_file($filename);
......@@ -1167,7 +1167,7 @@ sub dump_linebreak($)
print OUTPUT "/* DO NOT EDIT!! */\n\n";
print OUTPUT "#include \"wine/unicode.h\"\n\n";
dump_simple_mapping( "wine_linebreak_table", @break_table);
dump_two_level_mapping( "wine_linebreak_table", @break_table);
close OUTPUT;
save_file($filename);
......@@ -1243,7 +1243,7 @@ sub dump_shaping($)
print OUTPUT "/* DO NOT EDIT!! */\n\n";
print OUTPUT "#include \"wine/unicode.h\"\n\n";
dump_simple_mapping( "wine_shaping_table", @joining_table );
dump_two_level_mapping( "wine_shaping_table", @joining_table );
print OUTPUT "\nconst unsigned short wine_shaping_forms[256][4] =\n{\n";
for (my $i = 0x600; $i <= 0x6ff; $i++)
......@@ -1350,18 +1350,19 @@ sub DUMP_CASE_TABLE($@)
}
################################################################
# dump a simple char -> 16-bit value mapping table
sub dump_simple_mapping($@)
# compress a mapping table by removing identical rows
sub compress_array($@)
{
my $name = shift;
my $rows = shift;
my @table = @_;
my @array = (0) x 256;
my $len = @table / $rows;
my @array = (0) x $rows;
my %sequences;
# try to merge table rows
for (my $row = 0; $row < 256; $row++)
for (my $row = 0; $row < $rows; $row++)
{
my $rowtxt = sprintf "%04x" x 256, @table[($row<<8)..($row<<8)+255];
my $rowtxt = pack "S*", @table[($row * $len)..($row * $len + $len - 1)];
if (defined($sequences{$rowtxt}))
{
# reuse an existing row
......@@ -1371,9 +1372,18 @@ sub dump_simple_mapping($@)
{
# create a new row
$sequences{$rowtxt} = $array[$row] = $#array + 1;
push @array, @table[($row<<8)..($row<<8)+255];
push @array, @table[$row * $len..$row * $len + $len - 1];
}
}
return @array;
}
################################################################
# dump a simple char -> 16-bit value mapping table
sub dump_simple_mapping($@)
{
my $name = shift;
my @array = compress_array( 256, @_[0..65535] );
printf OUTPUT "const unsigned short %s[%d] =\n{\n", $name, $#array+1;
printf OUTPUT " /* offsets */\n%s,\n", DUMP_ARRAY( "0x%04x", 0, @array[0..255] );
......@@ -1381,6 +1391,22 @@ sub dump_simple_mapping($@)
}
################################################################
# dump a char -> 16-bit value mapping table using two-level tables
sub dump_two_level_mapping($@)
{
my $name = shift;
my @row_array = compress_array( 4096, @_[0..65535] );
my @array = compress_array( 256, @row_array[0..4095] );
for (my $i = 256; $i < @array; $i++) { $array[$i] += @array - 4096; }
printf OUTPUT "const unsigned short %s[%d] =\n{\n", $name, @array + @row_array - 4096;
printf OUTPUT " /* level 1 offsets */\n%s,\n", DUMP_ARRAY( "0x%04x", 0, @array[0..255] );
printf OUTPUT " /* level 2 offsets */\n%s,\n", DUMP_ARRAY( "0x%04x", 0, @array[256..$#array] );
printf OUTPUT " /* values */\n%s\n};\n", DUMP_ARRAY( "0x%04x", 0, @row_array[4096..$#row_array] );
}
################################################################
# dump a binary case mapping table in l_intl.nls format
sub dump_binary_case_table(@)
{
......
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