Reduce the size of the binary.

Use integers instead of pointers in Unicode tables. Saves 226 kb / 716 kb in the
compiled library.
This commit is contained in:
Michaël Meyer
2015-12-09 19:55:48 +01:00
parent 6b510deff2
commit 26436c9775
4 changed files with 6682 additions and 6677 deletions

View File

@@ -116,13 +116,14 @@ def str2c(string, prefix)
return "UTF8PROC_#{prefix}_#{string.upcase}"
end
def ary2c(array)
return "NULL" if array.nil?
return "UINT16_MAX" if array.nil?
unless $int_array_indicies[array]
$int_array_indicies[array] = $int_array.length
array.each { |entry| $int_array << entry }
$int_array << -1
end
return "utf8proc_sequences + #{$int_array_indicies[array]}"
raise "Array index out of bound" if $int_array_indicies[array] >= 65535
return "#{$int_array_indicies[array]}"
end
class UnicodeChar
@@ -305,7 +306,7 @@ end
$stdout << "};\n\n"
$stdout << "const utf8proc_property_t utf8proc_properties[] = {\n"
$stdout << " {0, 0, 0, 0, NULL, NULL, -1, -1, -1, -1, -1, false,false,false,false, UTF8PROC_BOUNDCLASS_OTHER, 0},\n"
$stdout << " {0, 0, 0, 0, UINT16_MAX, UINT16_MAX, -1, -1, -1, -1, -1, false,false,false,false, UTF8PROC_BOUNDCLASS_OTHER, 0},\n"
properties.each { |line|
$stdout << line
}