Commit 0cd0b153 authored by Christian Persch's avatar Christian Persch

Move unicode-nameslist.h data to ro. This saves over 8000 relocations (down to ~600).

Bug #503599.

svn path=/trunk/; revision=1647
parent 67193150
......@@ -470,6 +470,47 @@ EOT
# # etc
# };
#
sub print_names_list
{
my ($out, $nameslist_hash, $token, $variable_name) = @_;
print $out "static const char ", $variable_name, "_strings[] = \n";
my @names_pairs;
my %names_offsets;
my $offset = 0;
for my $wc (sort {$a <=> $b} keys %{$nameslist_hash})
{
next if not exists $nameslist_hash->{$wc}->{$token};
for my $value (@{$nameslist_hash->{$wc}->{$token}->{'values'}}) {
push @names_pairs, [$wc, $value];
next if exists $names_offsets{$value};
$names_offsets{$value} = $offset;
$offset += length($value) + 1;
my $printvalue = $value;
$printvalue =~ s/\\/\\\\/g;
$printvalue =~ s/\"/\\"/g;
printf $out (qq/ "\%s\\0"\n/, $printvalue);
}
}
print $out " ;\n\n";
print $out "static const UnicharStringIndex ", $variable_name, "[] = \n";
print $out "{\n";
foreach my $pair (@names_pairs) {
my ($wc, $value) = @{$pair};
printf $out (qq/ { 0x%04X, %d },\n/, $wc, $names_offsets{$value});
}
print $out " { (gunichar)(-1), 0 } /* end marker */ \n";
print $out "};\n\n";
}
sub process_nameslist_txt ($)
{
my ($nameslist_txt) = @_;
......@@ -498,8 +539,6 @@ sub process_nameslist_txt ($)
elsif ($line =~ /^\s+=\s+(.+)$/)
{
my $value = $1;
$value =~ s/\\/\\\\/g;
$value =~ s/\"/\\"/g;
if (not defined $nameslist_hash->{$wc}->{'='}->{'index'}) {
$nameslist_hash->{$wc}->{'='}->{'index'} = $equal_i;
......@@ -511,8 +550,6 @@ sub process_nameslist_txt ($)
elsif ($line =~ /^\s+\*\s+(.+)$/)
{
my $value = $1;
$value =~ s/\\/\\\\/g;
$value =~ s/\"/\\"/g;
if (not defined $nameslist_hash->{$wc}->{'*'}->{'index'}) {
$nameslist_hash->{$wc}->{'*'}->{'index'} = $star_i;
......@@ -524,8 +561,6 @@ sub process_nameslist_txt ($)
elsif ($line =~ /^\s+#\s+(.+)$/)
{
my $value = $1;
$value =~ s/\\/\\\\/g;
$value =~ s/\"/\\"/g;
if (not defined $nameslist_hash->{$wc}->{'#'}->{'index'}) {
$nameslist_hash->{$wc}->{'#'}->{'index'} = $pound_i;
......@@ -537,8 +572,6 @@ sub process_nameslist_txt ($)
elsif ($line =~ /^\s+:\s+(.+)$/)
{
my $value = $1;
$value =~ s/\\/\\\\/g;
$value =~ s/\"/\\"/g;
if (not defined $nameslist_hash->{$wc}->{':'}->{'index'}) {
$nameslist_hash->{$wc}->{':'}->{'index'} = $colon_i;
......@@ -574,14 +607,14 @@ sub process_nameslist_txt ($)
print $out "#include <glib/gunicode.h>\n\n";
print $out "typedef struct _UnicharString UnicharString;\n";
print $out "typedef struct _UnicharStringIndex UnicharStringIndex;\n";
print $out "typedef struct _UnicharUnichar UnicharUnichar;\n";
print $out "typedef struct _NamesList NamesList;\n\n";
print $out "struct _UnicharString\n";
print $out "struct _UnicharStringIndex\n";
print $out "{\n";
print $out " gunichar index;\n";
print $out " const gchar *value;\n";
print $out " guint32 string_index;\n";
print $out "}; \n\n";
print $out "struct _UnicharUnichar\n";
......@@ -600,41 +633,10 @@ sub process_nameslist_txt ($)
print $out " gint16 colons_index;\n";
print $out "};\n\n";
print $out "static const UnicharString names_list_equals[] = \n";
print $out "{\n";
for $wc (sort {$a <=> $b} keys %{$nameslist_hash})
{
next if not exists $nameslist_hash->{$wc}->{'='};
for my $value (@{$nameslist_hash->{$wc}->{'='}->{'values'}}) {
printf $out (qq/ { 0x%04X, "\%s" },\n/, $wc, $value);
}
}
print $out " { (gunichar)(-1), 0 }\n";
print $out "};\n\n";
print $out "static const UnicharString names_list_stars[] = \n";
print $out "{\n";
for $wc (sort {$a <=> $b} keys %{$nameslist_hash})
{
next if not exists $nameslist_hash->{$wc}->{'*'};
for my $value (@{$nameslist_hash->{$wc}->{'*'}->{'values'}}) {
printf $out (qq/ { 0x%04X, "\%s" },\n/, $wc, $value);
}
}
print $out " { (gunichar)(-1), 0 }\n";
print $out "};\n\n";
print $out "static const UnicharString names_list_pounds[] = \n";
print $out "{\n";
for $wc (sort {$a <=> $b} keys %{$nameslist_hash})
{
next if not exists $nameslist_hash->{$wc}->{'#'};
for my $value (@{$nameslist_hash->{$wc}->{'#'}->{'values'}}) {
printf $out (qq/ { 0x%04X, "\%s" },\n/, $wc, $value);
}
}
print $out " { (gunichar)(-1), 0 }\n";
print $out "};\n\n";
print_names_list($out, $nameslist_hash, '=', "names_list_equals");
print_names_list($out, $nameslist_hash, '*', "names_list_stars");
print_names_list($out, $nameslist_hash, '#', "names_list_pounds");
print_names_list($out, $nameslist_hash, ':', "names_list_colons");
print $out "static const UnicharUnichar names_list_exes[] = \n";
print $out "{\n";
......@@ -648,18 +650,6 @@ sub process_nameslist_txt ($)
print $out " { (gunichar)(-1), 0 }\n";
print $out "};\n\n";
print $out "static const UnicharString names_list_colons[] = \n";
print $out "{\n";
for $wc (sort {$a <=> $b} keys %{$nameslist_hash})
{
next if not exists $nameslist_hash->{$wc}->{':'};
for my $value (@{$nameslist_hash->{$wc}->{':'}->{'values'}}) {
printf $out (qq/ { 0x%04X, "\%s" },\n/, $wc, $value);
}
}
print $out " { (gunichar)(-1), 0 }\n";
print $out "};\n\n";
print $out "static const NamesList names_list[] =\n";
print $out "{\n";
for $wc (sort {$a <=> $b} keys %{$nameslist_hash})
......
......@@ -390,7 +390,7 @@ gucharmap_get_nameslist_exes (gunichar uc)
{
const NamesList *nl;
gunichar *exes;
gint i, count;
gunichar i, count;
nl = get_nameslist (uc);
......@@ -416,8 +416,8 @@ gucharmap_get_nameslist_equals (gunichar uc)
{
const NamesList *nl;
const gchar **equals;
gint i, count;
gunichar i, count;
nl = get_nameslist (uc);
if (nl == NULL || nl->equals_index == -1)
......@@ -429,7 +429,7 @@ gucharmap_get_nameslist_equals (gunichar uc)
equals = g_malloc ((count + 1) * sizeof (gchar *));
for (i = 0; i < count; i++)
equals[i] = names_list_equals[nl->equals_index + i].value;
equals[i] = names_list_equals_strings + names_list_equals[nl->equals_index + i].string_index;
equals[count] = NULL;
return equals;
......@@ -442,7 +442,7 @@ gucharmap_get_nameslist_stars (gunichar uc)
{
const NamesList *nl;
const gchar **stars;
gint i, count;
gunichar i, count;
nl = get_nameslist (uc);
......@@ -455,7 +455,7 @@ gucharmap_get_nameslist_stars (gunichar uc)
stars = g_malloc ((count + 1) * sizeof (gchar *));
for (i = 0; i < count; i++)
stars[i] = names_list_stars[nl->stars_index + i].value;
stars[i] = names_list_stars_strings + names_list_stars[nl->stars_index + i].string_index;
stars[count] = NULL;
return stars;
......@@ -468,7 +468,7 @@ gucharmap_get_nameslist_pounds (gunichar uc)
{
const NamesList *nl;
const gchar **pounds;
gint i, count;
gunichar i, count;
nl = get_nameslist (uc);
......@@ -481,7 +481,7 @@ gucharmap_get_nameslist_pounds (gunichar uc)
pounds = g_malloc ((count + 1) * sizeof (gchar *));
for (i = 0; i < count; i++)
pounds[i] = names_list_pounds[nl->pounds_index + i].value;
pounds[i] = names_list_pounds_strings + names_list_pounds[nl->pounds_index + i].string_index;
pounds[count] = NULL;
return pounds;
......@@ -494,8 +494,8 @@ gucharmap_get_nameslist_colons (gunichar uc)
{
const NamesList *nl;
const gchar **colons;
gint i, count;
gunichar i, count;
nl = get_nameslist (uc);
if (nl == NULL || nl->colons_index == -1)
......@@ -507,7 +507,7 @@ gucharmap_get_nameslist_colons (gunichar uc)
colons = g_malloc ((count + 1) * sizeof (gchar *));
for (i = 0; i < count; i++)
colons[i] = names_list_colons[nl->colons_index + i].value;
colons[i] = names_list_colons_strings + names_list_colons[nl->colons_index + i].string_index;
colons[count] = NULL;
return colons;
......
This diff is collapsed.
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