mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
Remove comp_step_table table
Reuse the pre-existing composition data.
This commit is contained in:
parent
89a5d17d58
commit
7041b701dd
@ -876,6 +876,7 @@ sub print_decomp
|
|||||||
print OUT " gunichar b;\n";
|
print OUT " gunichar b;\n";
|
||||||
print OUT "} decomposition_step;\n\n";
|
print OUT "} decomposition_step;\n\n";
|
||||||
|
|
||||||
|
# There's lots of room to optimize the following table...
|
||||||
print OUT "static const decomposition_step decomp_step_table[] =\n{\n";
|
print OUT "static const decomposition_step decomp_step_table[] =\n{\n";
|
||||||
$first = 1;
|
$first = 1;
|
||||||
my @steps = ();
|
my @steps = ();
|
||||||
@ -896,20 +897,6 @@ sub print_decomp
|
|||||||
}
|
}
|
||||||
print OUT "\n};\n\n";
|
print OUT "\n};\n\n";
|
||||||
|
|
||||||
print OUT "static const decomposition_step comp_step_table[] =\n{\n";
|
|
||||||
my @inverted;
|
|
||||||
@inverted = sort { @{$a}[1] <=> @{$b}[1] ||
|
|
||||||
@{$a}[2] <=> @{$b}[2] } @steps;
|
|
||||||
$first = 1;
|
|
||||||
foreach my $i ( 0 .. $#inverted )
|
|
||||||
{
|
|
||||||
print OUT ",\n"
|
|
||||||
if ! $first;
|
|
||||||
$first = 0;
|
|
||||||
printf OUT qq( { 0x%05x, 0x%05x, 0x%05x }), $inverted[$i][0], $inverted[$i][1], $inverted[$i][2];
|
|
||||||
}
|
|
||||||
print OUT "\n};\n\n";
|
|
||||||
|
|
||||||
print OUT "#endif /* DECOMP_H */\n";
|
print OUT "#endif /* DECOMP_H */\n";
|
||||||
|
|
||||||
printf STDERR "Generated %d bytes in decomp tables\n", $bytes_out;
|
printf STDERR "Generated %d bytes in decomp tables\n", $bytes_out;
|
||||||
|
@ -568,44 +568,6 @@ decompose_hangul_step (gunichar ch,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
compose_hangul_step (gunichar a,
|
|
||||||
gunichar b,
|
|
||||||
gunichar *ch)
|
|
||||||
{
|
|
||||||
gint LIndex, SIndex;
|
|
||||||
|
|
||||||
/* first try L,V -> LV */
|
|
||||||
LIndex = a - LBase;
|
|
||||||
if (0 <= LIndex && LIndex < LCount)
|
|
||||||
{
|
|
||||||
gint VIndex;
|
|
||||||
|
|
||||||
VIndex = b - VBase;
|
|
||||||
if (0 <= VIndex && VIndex < VCount)
|
|
||||||
{
|
|
||||||
*ch = SBase + (LIndex * VCount + VIndex) * TCount;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* next try LV,T -> LVT */
|
|
||||||
SIndex = a - SBase;
|
|
||||||
if (0 <= SIndex && SIndex < SCount && (SIndex % TCount) == 0)
|
|
||||||
{
|
|
||||||
gint TIndex;
|
|
||||||
|
|
||||||
TIndex = b - TBase;
|
|
||||||
if (0 < TIndex && TIndex < TCount)
|
|
||||||
{
|
|
||||||
*ch = a + TIndex;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_unichar_decompose:
|
* g_unichar_decompose:
|
||||||
* @ch: a Unicode character
|
* @ch: a Unicode character
|
||||||
@ -650,6 +612,7 @@ g_unichar_decompose (gunichar ch,
|
|||||||
if (decompose_hangul_step (ch, a, b))
|
if (decompose_hangul_step (ch, a, b))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
/* TODO use bsearch() */
|
||||||
if (ch >= decomp_step_table[start].ch &&
|
if (ch >= decomp_step_table[start].ch &&
|
||||||
ch <= decomp_step_table[end - 1].ch)
|
ch <= decomp_step_table[end - 1].ch)
|
||||||
{
|
{
|
||||||
@ -709,34 +672,9 @@ g_unichar_compose (gunichar a,
|
|||||||
gunichar b,
|
gunichar b,
|
||||||
gunichar *ch)
|
gunichar *ch)
|
||||||
{
|
{
|
||||||
gint start = 0;
|
if (combine (a, b, ch))
|
||||||
gint end = G_N_ELEMENTS (comp_step_table);
|
|
||||||
|
|
||||||
if (compose_hangul_step (a, b, ch))
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (a >= comp_step_table[start].a &&
|
|
||||||
a <= comp_step_table[end - 1].a)
|
|
||||||
{
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
gint half = (start + end) / 2;
|
|
||||||
const decomposition_step *p = &(comp_step_table[half]);
|
|
||||||
if (a == p->a && b == p->b)
|
|
||||||
{
|
|
||||||
*ch = p->ch;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if (half == start)
|
|
||||||
break;
|
|
||||||
else if (a > p->a || (a == p->a && b > p->b))
|
|
||||||
start = half;
|
|
||||||
else
|
|
||||||
end = half;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*ch = 0;
|
*ch = 0;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
1020
glib/gunidecomp.h
1020
glib/gunidecomp.h
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user