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:
parent
6b510deff2
commit
26436c9775
@ -116,13 +116,14 @@ def str2c(string, prefix)
|
|||||||
return "UTF8PROC_#{prefix}_#{string.upcase}"
|
return "UTF8PROC_#{prefix}_#{string.upcase}"
|
||||||
end
|
end
|
||||||
def ary2c(array)
|
def ary2c(array)
|
||||||
return "NULL" if array.nil?
|
return "UINT16_MAX" if array.nil?
|
||||||
unless $int_array_indicies[array]
|
unless $int_array_indicies[array]
|
||||||
$int_array_indicies[array] = $int_array.length
|
$int_array_indicies[array] = $int_array.length
|
||||||
array.each { |entry| $int_array << entry }
|
array.each { |entry| $int_array << entry }
|
||||||
$int_array << -1
|
$int_array << -1
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
class UnicodeChar
|
class UnicodeChar
|
||||||
@ -305,7 +306,7 @@ end
|
|||||||
$stdout << "};\n\n"
|
$stdout << "};\n\n"
|
||||||
|
|
||||||
$stdout << "const utf8proc_property_t utf8proc_properties[] = {\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|
|
properties.each { |line|
|
||||||
$stdout << line
|
$stdout << line
|
||||||
}
|
}
|
||||||
|
|||||||
@ -357,10 +357,10 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc,
|
|||||||
category == UTF8PROC_CATEGORY_ME) return 0;
|
category == UTF8PROC_CATEGORY_ME) return 0;
|
||||||
}
|
}
|
||||||
if (options & UTF8PROC_CASEFOLD) {
|
if (options & UTF8PROC_CASEFOLD) {
|
||||||
if (property->casefold_mapping) {
|
if (property->casefold_mapping != UINT16_MAX) {
|
||||||
const utf8proc_int32_t *casefold_entry;
|
const utf8proc_int32_t *casefold_entry;
|
||||||
utf8proc_ssize_t written = 0;
|
utf8proc_ssize_t written = 0;
|
||||||
for (casefold_entry = property->casefold_mapping;
|
for (casefold_entry = &utf8proc_sequences[property->casefold_mapping];
|
||||||
*casefold_entry >= 0; casefold_entry++) {
|
*casefold_entry >= 0; casefold_entry++) {
|
||||||
written += utf8proc_decompose_char(*casefold_entry, dst+written,
|
written += utf8proc_decompose_char(*casefold_entry, dst+written,
|
||||||
(bufsize > written) ? (bufsize - written) : 0, options,
|
(bufsize > written) ? (bufsize - written) : 0, options,
|
||||||
@ -371,11 +371,11 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options & (UTF8PROC_COMPOSE|UTF8PROC_DECOMPOSE)) {
|
if (options & (UTF8PROC_COMPOSE|UTF8PROC_DECOMPOSE)) {
|
||||||
if (property->decomp_mapping &&
|
if (property->decomp_mapping != UINT16_MAX &&
|
||||||
(!property->decomp_type || (options & UTF8PROC_COMPAT))) {
|
(!property->decomp_type || (options & UTF8PROC_COMPAT))) {
|
||||||
const utf8proc_int32_t *decomp_entry;
|
const utf8proc_int32_t *decomp_entry;
|
||||||
utf8proc_ssize_t written = 0;
|
utf8proc_ssize_t written = 0;
|
||||||
for (decomp_entry = property->decomp_mapping;
|
for (decomp_entry = &utf8proc_sequences[property->decomp_mapping];
|
||||||
*decomp_entry >= 0; decomp_entry++) {
|
*decomp_entry >= 0; decomp_entry++) {
|
||||||
written += utf8proc_decompose_char(*decomp_entry, dst+written,
|
written += utf8proc_decompose_char(*decomp_entry, dst+written,
|
||||||
(bufsize > written) ? (bufsize - written) : 0, options,
|
(bufsize > written) ? (bufsize - written) : 0, options,
|
||||||
|
|||||||
@ -132,6 +132,10 @@ extern "C" {
|
|||||||
#define SSIZE_MAX ((size_t)SIZE_MAX/2)
|
#define SSIZE_MAX ((size_t)SIZE_MAX/2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef UINT16_MAX
|
||||||
|
# define UINT16_MAX ~(utf8proc_uint16_t)0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option flags used by several functions in the library.
|
* Option flags used by several functions in the library.
|
||||||
*/
|
*/
|
||||||
@ -238,8 +242,8 @@ typedef struct utf8proc_property_struct {
|
|||||||
* @see utf8proc_decomp_type_t.
|
* @see utf8proc_decomp_type_t.
|
||||||
*/
|
*/
|
||||||
utf8proc_propval_t decomp_type;
|
utf8proc_propval_t decomp_type;
|
||||||
const utf8proc_int32_t *decomp_mapping;
|
utf8proc_uint16_t decomp_mapping;
|
||||||
const utf8proc_int32_t *casefold_mapping;
|
utf8proc_uint16_t casefold_mapping;
|
||||||
utf8proc_int32_t uppercase_mapping;
|
utf8proc_int32_t uppercase_mapping;
|
||||||
utf8proc_int32_t lowercase_mapping;
|
utf8proc_int32_t lowercase_mapping;
|
||||||
utf8proc_int32_t titlecase_mapping;
|
utf8proc_int32_t titlecase_mapping;
|
||||||
|
|||||||
13336
utf8proc_data.c
13336
utf8proc_data.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user