Commit 91702626 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Patch from Andrew Taylor to improve tables and reduce relocations by using

Tue Nov 13 21:25:35 2001  Owen Taylor  <otaylor@redhat.com>

	* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
	gunichartables.h, gunicomp.h, gunidecomp.[ch],
	guniprop.c}: Patch from Andrew Taylor to improve
	tables and reduce relocations by using indices
	rather than pointers. (#64433)

	* tests/unicode-normalize.c (main): Fix for changes
	to g_strsplit().
parent 4abd1660
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
Tue Nov 13 21:25:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gen-unicode-tables.pl,gunibreak.c,gunibreak.h,
gunichartables.h, gunicomp.h, gunidecomp.[ch],
guniprop.c}: Patch from Andrew Taylor to improve
tables and reduce relocations by using indices
rather than pointers. (#64433)
* tests/unicode-normalize.c (main): Fix for changes
to g_strsplit().
2001-11-12 Darin Adler <darin@bentspoon.com>
* glib/gstrfuncs.c: (g_strsplit): Fix max_tokens == 1 case to
......
......@@ -18,6 +18,9 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# Contributer(s):
# Andrew Taylor <andrew.taylor@montage.ca>
# gen-unicode-tables.pl - Generate tables for libunicode from Unicode data.
# See http://www.unicode.org/Public/UNIDATA/UnicodeCharacterDatabase.html
# Usage: gen-unicode-tables.pl [-decomp | -both] UNICODE-VERSION UnicodeData.txt LineBreak.txt SpecialCasing.txt CaseFolding.txt
......@@ -25,8 +28,6 @@
# you will.
# FIXME:
# * We could save even more space in the generated table by using
# indexes and not pointers.
# * For decomp table it might make sense to use a shift count other
# than 8. We could easily compute the perfect shift count.
......@@ -525,18 +526,22 @@ sub print_tables
printf OUT "#define G_UNICODE_LAST_CHAR 0x%04x\n\n", $last;
printf OUT "#define G_UNICODE_MAX_TABLE_INDEX 1000\n\n";
$table_index = 0;
printf OUT "static const char type_data[][256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
$row[$count / 256] = &print_row ($count, '(char *) ', 'char', 1,
'page', \&fetch_type);
$row[$count / 256] = &print_row ($count, 1, \&fetch_type);
}
printf OUT "\n};\n\n";
print OUT "static const char *type_table[256] = {\n";
print OUT "static const short type_table[256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
print OUT ",\n" if $count > 0;
print OUT " ", $row[$count / 256];
$bytes_out += 4;
$bytes_out += 2;
}
print OUT "\n};\n\n";
......@@ -545,17 +550,20 @@ sub print_tables
# Now print attribute table.
#
$table_index = 0;
printf OUT "static const unsigned short attr_data[][256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
$row[$count / 256] = &print_row ($count, '', 'unsigned short', 2,
'attrpage', \&fetch_attr);
$row[$count / 256] = &print_row ($count, 2, \&fetch_attr);
}
print OUT "static const unsigned short *attr_table[256] = {\n";
printf OUT "\n};\n\n";
print OUT "static const short attr_table[256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
print OUT ",\n" if $count > 0;
print OUT " ", $row[$count / 256];
$bytes_out += 4;
$bytes_out += 2;
}
print OUT "\n};\n\n";
......@@ -611,10 +619,9 @@ sub fetch_attr
}
}
# Print a single "row" of a two-level table.
sub print_row
{
my ($start, $def_pfx, $typname, $typsize, $name, $fetcher) = @_;
my ($start, $typsize, $fetcher) = @_;
my ($i);
my (@values);
......@@ -631,11 +638,12 @@ sub print_row
}
if ($flag)
{
return $def_pfx . $values[0];
return $values[0] . " + G_UNICODE_MAX_TABLE_INDEX";
}
printf OUT "static const %s %s%d[256] = {\n ", $typname, $name, $start / 256;
my ($column) = 2;
printf OUT ",\n" if ($table_index != 0);
printf OUT " { /* page %d, index %d */\n ", $start / 256, $table_index;
my ($column) = 4;
for ($i = $start; $i < $start + 256; ++$i)
{
print OUT ", "
......@@ -643,17 +651,17 @@ sub print_row
my ($text) = $values[$i - $start];
if (length ($text) + $column + 2 > 78)
{
print OUT "\n ";
$column = 2;
print OUT "\n ";
$column = 4;
}
print OUT $text;
$column += length ($text) + 2;
}
print OUT "\n};\n\n";
print OUT "\n }";
$bytes_out += 256 * $typsize;
return sprintf "%s%d", $name, $start / 256;
return sprintf "%d /* page %d */", $table_index++, $start / 256;
}
# Generate the character decomposition header.
......@@ -674,20 +682,23 @@ sub print_decomp
printf OUT "#define G_UNICODE_LAST_CHAR 0x%04x\n\n", $last;
printf OUT "#define G_UNICODE_MAX_TABLE_INDEX 1000\n\n";
my ($count, @row);
$table_index = 0;
printf OUT "static const unsigned char cclass_data[][256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
$row[$count / 256] = &print_row ($count, '(unsigned char *) ',
'unsigned char', 1, 'cclass',
\&fetch_cclass);
$row[$count / 256] = &print_row ($count, 1, \&fetch_cclass);
}
printf OUT "\n};\n\n";
print OUT "static const unsigned char *combining_class_table[256] = {\n";
print OUT "static const short combining_class_table[256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
print OUT ",\n" if $count > 0;
print OUT " ", $row[$count / 256];
$bytes_out += 4;
$bytes_out += 2;
}
print OUT "\n};\n\n";
......@@ -776,19 +787,22 @@ sub print_line_break
printf OUT "#define G_UNICODE_LAST_CHAR 0x%04x\n\n", $last;
printf OUT "#define G_UNICODE_MAX_TABLE_INDEX 1000\n\n";
$table_index = 0;
printf OUT "static const char break_property_data[][256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
$row[$count / 256] = &print_row ($count, '(char *) ', 'char', 1,
'page',
\&fetch_break_type);
$row[$count / 256] = &print_row ($count, 1, \&fetch_break_type);
}
printf OUT "\n};\n\n";
print OUT "static const char *break_property_table[256] = {\n";
print OUT "static const short break_property_table[256] = {\n";
for ($count = 0; $count <= $last; $count += 256)
{
print OUT ",\n" if $count > 0;
print OUT " ", $row[$count / 256];
$bytes_out += 4;
$bytes_out += 2;
}
print OUT "\n};\n\n";
......@@ -1039,14 +1053,15 @@ sub output_composition_table
# Output lookup table
my @row;
$table_index = 0;
printf OUT "static const gushort compose_data[][256] = {\n";
for (my $count = 0; $count <= $last; $count += 256)
{
$row[$count / 256] = &print_row ($count, '(gushort *) ', 'gushort', 2,
'compose_page',
sub { exists $vals{$_[0]} ? $vals{$_[0]} : 0; });
$row[$count / 256] = &print_row ($count, 2, sub { exists $vals{$_[0]} ? $vals{$_[0]} : 0; });
}
printf OUT "\n};\n\n";
print OUT "static const unsigned short *compose_table[256] = {\n";
print OUT "static const short compose_table[256] = {\n";
for (my $count = 0; $count <= $last; $count += 256)
{
print OUT ",\n" if $count > 0;
......
......@@ -26,12 +26,10 @@
#include <stdlib.h>
/* We cheat a bit and cast type values to (char *). We detect these
using the &0xff trick. */
#define TPROP(Page, Char) \
(((GPOINTER_TO_INT(break_property_table[Page]) & 0xff) == GPOINTER_TO_INT(break_property_table[Page])) \
? GPOINTER_TO_INT(break_property_table[Page]) \
: (break_property_table[Page][Char]))
((break_property_table[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (break_property_table[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (break_property_data[break_property_table[Page]][Char]))
#define PROP(Char) (((Char) > (G_UNICODE_LAST_CHAR)) ? G_UNICODE_UNASSIGNED : TPROP ((Char) >> 8, (Char) & 0xff))
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -27,13 +27,10 @@
#include <stdlib.h>
/* We cheat a bit and cast type values to (char *). We detect these
using the &0xff trick. */
#define CC(Page, Char) \
((((GPOINTER_TO_INT(combining_class_table[Page])) & 0xff) \
== GPOINTER_TO_INT(combining_class_table[Page])) \
? GPOINTER_TO_INT(combining_class_table[Page]) \
: (combining_class_table[Page][Char]))
((combining_class_table[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (combining_class_table[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (cclass_data[combining_class_table[Page]][Char]))
#define COMBINING_CLASS(Char) \
(((Char) > (G_UNICODE_LAST_CHAR)) ? 0 : CC((Char) >> 8, (Char) & 0xff))
......@@ -181,10 +178,9 @@ g_unicode_canonical_decomposition (gunichar ch,
}
#define CI(Page, Char) \
((((GPOINTER_TO_INT(compose_table[Page])) & 0xff) \
== GPOINTER_TO_INT(compose_table[Page])) \
? GPOINTER_TO_INT(compose_table[Page]) \
: (compose_table[Page][Char]))
((compose_table[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (compose_table[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (compose_data[compose_table[Page]][Char]))
#define COMPOSE_INDEX(Char) \
(((Char) > (G_UNICODE_LAST_CHAR)) ? 0 : CI((Char) >> 8, (Char) & 0xff))
......
This diff is collapsed.
......@@ -29,14 +29,15 @@
#include <locale.h>
#define ATTTABLE(Page, Char) \
((attr_table[Page] == 0) ? 0 : (attr_table[Page][Char]))
((attr_table[Page] == G_UNICODE_MAX_TABLE_INDEX) ? 0 : (attr_data[attr_table[Page]][Char]))
/* We cheat a bit and cast type values to (char *). We detect these
using the &0xff trick. */
#define TTYPE(Page, Char) \
(((GPOINTER_TO_INT(type_table[Page]) & 0xff) == GPOINTER_TO_INT(type_table[Page])) \
? GPOINTER_TO_INT(type_table[Page]) \
: (type_table[Page][Char]))
((type_table[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (type_table[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (type_data[type_table[Page]][Char]))
#define TYPE(Char) (((Char) > (G_UNICODE_LAST_CHAR)) ? G_UNICODE_UNASSIGNED : TTYPE ((Char) >> 8, (Char) & 0xff))
......
......@@ -170,6 +170,9 @@ int main (int argc, char **argv)
}
columns = g_strsplit (buffer->str, ";", -1);
if (!columns[0])
goto next;
if (!process_one (line, columns))
return 1;
g_strfreev (columns);
......
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