summaryrefslogtreecommitdiff
path: root/source3/lib/util_unistr.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-15 07:14:40 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-15 07:14:40 +0000
commit4b7850663e209fbcd650bcacab3d61655e829ed2 (patch)
treee8ec69d531a37d737644de830f9d638823e2fc64 /source3/lib/util_unistr.c
parenta4e537322ffa6442a7491956ecf71484c848ae04 (diff)
downloadsamba-4b7850663e209fbcd650bcacab3d61655e829ed2.tar.gz
samba-4b7850663e209fbcd650bcacab3d61655e829ed2.tar.bz2
samba-4b7850663e209fbcd650bcacab3d61655e829ed2.zip
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)
Diffstat (limited to 'source3/lib/util_unistr.c')
-rw-r--r--source3/lib/util_unistr.c48
1 files changed, 39 insertions, 9 deletions
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;