From 4b7850663e209fbcd650bcacab3d61655e829ed2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Apr 2000 07:14:40 +0000 Subject: a quick hack to reduce the size of the unicode map table headers from 3MB to 250k. I split the table into 3 sections, after noticing that 5/6 of the table was empty. (This used to be commit c1496736bbdb7f6bf1eb43a54f883e5f41a4d39e) --- source3/lib/util_unistr.c | 48 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'source3/lib/util_unistr.c') diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 8a02878c13..3144e58b2a 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -1030,6 +1030,11 @@ smb_ucs2_t *strdup_w(const smb_ucs2_t *s) /******************************************************************* Mapping tables for UNICODE character. Allows toupper/tolower and isXXX functions to work. + + tridge: split into 2 pieces. This saves us 5/6 of the memory + with a small speed penalty + The magic constants are the lower/upper range of the tables two + parts ********************************************************************/ typedef struct { @@ -1038,17 +1043,42 @@ typedef struct { unsigned char flags; } smb_unicode_table_t; -static smb_unicode_table_t map_table[] = { -#include "unicode_map_table.h" +static smb_unicode_table_t map_table1[] = { +#include "unicode_map_table1.h" +}; + +static smb_unicode_table_t map_table2[] = { +#include "unicode_map_table2.h" }; +static unsigned char map_table_flags(smb_ucs2_t v) +{ + if (v < 9450) return map_table1[v].flags; + if (v >= 64256) return map_table2[v - 64256].flags; + return 0; +} + +static smb_ucs2_t map_table_lower(smb_ucs2_t v) +{ + if (v < 9450) return map_table1[v].lower; + if (v >= 64256) return map_table2[v - 64256].lower; + return v; +} + +static smb_ucs2_t map_table_upper(smb_ucs2_t v) +{ + if (v < 9450) return map_table1[v].upper; + if (v >= 64256) return map_table2[v - 64256].upper; + return v; +} + /******************************************************************* Is an upper case wchar. ********************************************************************/ int isupper_w( smb_ucs2_t val) { - return (map_table[val].flags & UNI_UPPER); + return (map_table_flags(val) & UNI_UPPER); } /******************************************************************* @@ -1057,7 +1087,7 @@ int isupper_w( smb_ucs2_t val) int islower_w( smb_ucs2_t val) { - return (map_table[val].flags & UNI_LOWER); + return (map_table_flags(val) & UNI_LOWER); } /******************************************************************* @@ -1066,7 +1096,7 @@ int islower_w( smb_ucs2_t val) int isdigit_w( smb_ucs2_t val) { - return (map_table[val].flags & UNI_DIGIT); + return (map_table_flags(val) & UNI_DIGIT); } /******************************************************************* @@ -1075,7 +1105,7 @@ int isdigit_w( smb_ucs2_t val) int isxdigit_w( smb_ucs2_t val) { - return (map_table[val].flags & UNI_XDIGIT); + return (map_table_flags(val) & UNI_XDIGIT); } /******************************************************************* @@ -1084,7 +1114,7 @@ int isxdigit_w( smb_ucs2_t val) int isspace_w( smb_ucs2_t val) { - return (map_table[val].flags & UNI_SPACE); + return (map_table_flags(val) & UNI_SPACE); } /******************************************************************* @@ -1093,7 +1123,7 @@ int isspace_w( smb_ucs2_t val) smb_ucs2_t toupper_w( smb_ucs2_t val ) { - return map_table[val].upper; + return map_table_upper(val); } /******************************************************************* @@ -1102,7 +1132,7 @@ smb_ucs2_t toupper_w( smb_ucs2_t val ) smb_ucs2_t tolower_w( smb_ucs2_t val ) { - return map_table[val].lower; + return map_table_lower(val); } static smb_ucs2_t *last_ptr = NULL; -- cgit