Skip to content
Snippets Groups Projects
Commit 2af81dfe authored by Michael Paquier's avatar Michael Paquier
Browse files

pg_sasl_prepare: reduce size of conversion table

Characters with a class of 0 and no decompositions don't really need
to be in the table and any abscence of such characters in the table
would mean that they have the following limitations. This reduces the
size of the table from 2.4MB to 570kB, which is already a good win.
parent 148a6dee
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -48,6 +48,10 @@ while (my $line = <$FH>)
 
# Skip codes longer than 4 bytes, or 8 characters.
next if length($code) > 8;
# Skip characters with no decompositions and a class of 0.
next if $elts[3] eq '0' && $elts[5] eq '';
$input_lines++;
}
close $FH;
Loading
Loading
@@ -89,6 +93,10 @@ while ( my $line = <$INPUT> )
# Skip codes longer than 4 bytes, or 8 characters.
next if length($code) > 8;
 
# Skip characters with no decompositions and a class of 0.
# to reduce the table size.
next if $elts[3] eq '0' && $elts[5] eq '';
# Print a comma for all items except the first one.
if ($first_item)
{
Loading
Loading
Loading
Loading
@@ -129,8 +129,12 @@ get_decomposed_size(uint32 code)
 
entry = get_code_entry(code);
 
/* Just count current code if no other decompositions */
if (entry->codes[0] == 0x0)
/*
* Just count current code if no other decompositions. A NULL entry
* is equivalent to a character with class 0 and no decompositions,
* so just leave.
*/
if (entry == NULL || entry->codes[0] == 0x0)
return 1;
 
/*
Loading
Loading
@@ -196,9 +200,11 @@ decompose_code(uint32 code, int **result, int *current)
 
/*
* Just fill in with the current decomposition if there are no
* decomposition codes to recurse to.
* decomposition codes to recurse to. A NULL entry is equivalent
* to a character with class 0 and no decompositions, so just leave
* also in this case.
*/
if (entry->codes[0] == 0x0)
if (entry == NULL || entry->codes[0] == 0x0)
{
int *res = *result;
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment