diff options
author | unknown <bar@bar.mysql.r18.ru> | 2002-10-10 16:52:22 +0500 |
---|---|---|
committer | unknown <bar@bar.mysql.r18.ru> | 2002-10-10 16:52:22 +0500 |
commit | 72174d5b8207363aaf22dbc7b0b85d9bfa9505ab (patch) | |
tree | e790007e93397bb7bde6736323e58af58b68ba77 | |
parent | b9bb3534f1ca2af09f636253650b68b0f2840f65 (diff) | |
download | mariadb-git-72174d5b8207363aaf22dbc7b0b85d9bfa9505ab.tar.gz |
Move hash_sort and hash_caseup into CHARSET_INFO for all charsets
-rw-r--r-- | heap/hp_hash.c | 27 | ||||
-rw-r--r-- | include/m_ctype.h | 8 | ||||
-rw-r--r-- | mysys/charset.c | 2 | ||||
-rw-r--r-- | mysys/hash.c | 36 | ||||
-rw-r--r-- | strings/ctype-big5.c | 4 | ||||
-rw-r--r-- | strings/ctype-czech.c | 4 | ||||
-rw-r--r-- | strings/ctype-euc_kr.c | 4 | ||||
-rw-r--r-- | strings/ctype-gb2312.c | 4 | ||||
-rw-r--r-- | strings/ctype-gbk.c | 4 | ||||
-rw-r--r-- | strings/ctype-latin1_de.c | 4 | ||||
-rw-r--r-- | strings/ctype-simple.c | 53 | ||||
-rw-r--r-- | strings/ctype-sjis.c | 4 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 4 | ||||
-rw-r--r-- | strings/ctype-ujis.c | 4 | ||||
-rw-r--r-- | strings/ctype-win1250ch.c | 4 | ||||
-rw-r--r-- | strings/ctype.c | 92 |
16 files changed, 132 insertions, 126 deletions
diff --git a/heap/hp_hash.c b/heap/hp_hash.c index b0533e9c7a4..ea48bd0c947 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -214,18 +214,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) } if (seg->type == HA_KEYTYPE_TEXT) { - if (seg->charset->hash_sort) - seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,&nr2); - else - { - register uchar *sort_order=seg->charset->sort_order; - for (; pos < (uchar*) key ; pos++) - { - nr^=(ulong) ((((uint) nr & 63)+nr2) * - ((uint) sort_order[(uint) *pos])) + (nr << 8); - nr2+=3; - } - } + seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,&nr2); } else { @@ -260,19 +249,7 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) } if (seg->type == HA_KEYTYPE_TEXT) { - if (seg->charset->hash_sort) - seg->charset->hash_sort(seg->charset,pos,end-pos,&nr,&nr2); - else - { - register uchar *sort_order=seg->charset->sort_order; - - for (; pos < end ; pos++) - { - nr^=(ulong) ((((uint) nr & 63)+nr2)* - ((uint) sort_order[(uint) *pos]))+ (nr << 8); - nr2+=3; - } - } + seg->charset->hash_sort(seg->charset,pos,end-pos,&nr,&nr2); } else { diff --git a/include/m_ctype.h b/include/m_ctype.h index 70551f31c57..e4bc9be3378 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -126,6 +126,14 @@ extern my_bool init_compiled_charsets(myf flags); extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, uint); extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, const uchar *, uint); +extern uint my_hash_caseup_simple(CHARSET_INFO *cs, + const byte *key, uint len); + +extern void my_hash_sort_simple(CHARSET_INFO *cs, + const uchar *key, uint len, + ulong *nr1, ulong *nr2); + + /* Functions for 8bit */ extern void my_caseup_str_8bit(CHARSET_INFO *, char *); extern void my_casedn_str_8bit(CHARSET_INFO *, char *); diff --git a/mysys/charset.c b/mysys/charset.c index 742163e9220..9c977c7d145 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -386,6 +386,8 @@ static CHARSET_INFO *add_charset(CHARSET_INFO *cs, myf flags) cs->strncasecmp = my_strncasecmp_8bit; cs->mb_wc = my_mb_wc_8bit; cs->wc_mb = my_wc_mb_8bit; + cs->hash_caseup = my_hash_caseup_simple; + cs->hash_sort = my_hash_sort_simple; set_max_sort_char(cs); create_fromuni(cs); diff --git a/mysys/hash.c b/mysys/hash.c index 43e6981f79d..2ef17be5341 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -32,7 +32,6 @@ static uint hash_mask(uint hashnr,uint buffmax,uint maxlength); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static uint calc_hashnr(CHARSET_INFO *cs,const byte *key,uint length); -static uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key,uint length); static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); @@ -60,12 +59,7 @@ _hash_init(HASH *hash,CHARSET_INFO *charset, hash->flags=flags; hash->charset=charset; if (flags & HASH_CASE_INSENSITIVE) - { - if (charset->hash_caseup) - hash->calc_hashnr=charset->hash_caseup; - else - hash->calc_hashnr=calc_hashnr_caseup; - } + hash->calc_hashnr=charset->hash_caseup; else hash->calc_hashnr=calc_hashnr; DBUG_RETURN(0); @@ -132,22 +126,6 @@ static uint calc_hashnr(CHARSET_INFO *cs __attribute__((unused)), return((uint) nr); } - /* Calc hashvalue for a key, case indepenently */ - -static uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key,uint length) -{ - register uint nr=1, nr2=4; - register uchar *map=cs->to_upper; - - while (length--) - { - nr^= (((nr & 63)+nr2)* - ((uint) (uchar) map[(uchar)*key++])) + (nr << 8); - nr2+=3; - } - return((uint) nr); -} - #else /* @@ -175,18 +153,6 @@ uint calc_hashnr(CHARSET_INFO *cs, const byte *key, uint len) return (hash); } -uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key, uint len) -{ - const byte *end=key+len; - uint hash; - for (hash = 0; key < end; key++) - { - hash *= 16777619; - hash ^= (uint) (uchar) my_toupper(cs,*key); - } - return (hash); -} - #endif diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index f83cf0cffeb..b9011ac12aa 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6245,8 +6245,8 @@ CHARSET_INFO my_charset_big5 = NULL, /* tosort */ my_strcasecmp_mb, my_strncasecmp_mb, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 3060c29dbac..e6cab722a8e 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -623,8 +623,8 @@ CHARSET_INFO my_charset_czech = NULL, /* tosort */ my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 5f5129921b9..a7d6044b378 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8662,8 +8662,8 @@ CHARSET_INFO my_charset_euc_kr = my_tosort_8bit, my_strcasecmp_mb, my_strncasecmp_mb, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 9823eceee5b..e931c7c1f31 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5712,8 +5712,8 @@ CHARSET_INFO my_charset_gb2312 = my_tosort_8bit, my_strcasecmp_mb, my_strncasecmp_mb, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index fd70dac2123..0f2de81ccb6 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9900,8 +9900,8 @@ CHARSET_INFO my_charset_gbk = NULL, /* tosort */ my_strcasecmp_mb, my_strncasecmp_mb, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-latin1_de.c b/strings/ctype-latin1_de.c index b34b091d679..040bd11b5e9 100644 --- a/strings/ctype-latin1_de.c +++ b/strings/ctype-latin1_de.c @@ -441,8 +441,8 @@ CHARSET_INFO my_charset_latin1_de = NULL, /* tosort */ my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 8553f83f380..f27b113376b 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -118,3 +118,56 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, } return MY_CS_ILUNI; } + + + +#ifndef NEW_HASH_FUNCTION + + /* Calc hashvalue for a key, case indepenently */ + +uint my_hash_caseup_simple(CHARSET_INFO *cs, const byte *key, uint length) +{ + register uint nr=1, nr2=4; + register uchar *map=cs->to_upper; + + while (length--) + { + nr^= (((nr & 63)+nr2)* + ((uint) (uchar) map[(uchar)*key++])) + (nr << 8); + nr2+=3; + } + return((uint) nr); +} + +#else + +uint my_hash_caseup_simple(CHARSET_INFO *cs, const byte *key, uint len) +{ + const byte *end=key+len; + uint hash; + for (hash = 0; key < end; key++) + { + hash *= 16777619; + hash ^= (uint) (uchar) my_toupper(cs,*key); + } + return (hash); +} + +#endif + +void my_hash_sort_simple(CHARSET_INFO *cs, + const uchar *key, uint len, + ulong *nr1, ulong *nr2) +{ + register uchar *sort_order=cs->sort_order; + const uchar *pos = key; + + key+= len; + + for (; pos < (uchar*) key ; pos++) + { + nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) * + ((uint) sort_order[(uint) *pos])) + (nr1[0] << 8); + nr2[0]+=3; + } +} diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index f61d3753536..9c8ac8d0c16 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4487,8 +4487,8 @@ CHARSET_INFO my_charset_sjis = NULL, /* tosort */ my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 1a4be5b3f9a..88549e7ee69 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -715,8 +715,8 @@ CHARSET_INFO my_charset_tis620 = NULL, /* tosort */ my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 086e3362f8b..cb1da080951 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8456,8 +8456,8 @@ CHARSET_INFO my_charset_ujis = my_tosort_8bit, my_strcasecmp_mb, my_strncasecmp_mb, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index e738d7727bc..f64eddd2c2b 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -649,8 +649,8 @@ CHARSET_INFO my_charset_win1250ch = NULL, /* tosort */ my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }; diff --git a/strings/ctype.c b/strings/ctype.c index 91e20508558..379669adb5f 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -2832,8 +2832,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -2868,8 +2868,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -2903,8 +2903,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -2938,8 +2938,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -2974,8 +2974,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3009,8 +3009,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3044,8 +3044,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3079,8 +3079,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3115,8 +3115,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3150,8 +3150,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3185,8 +3185,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3220,8 +3220,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3255,8 +3255,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3290,8 +3290,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3325,8 +3325,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3361,8 +3361,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3396,8 +3396,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3432,8 +3432,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3468,8 +3468,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3503,8 +3503,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3538,8 +3538,8 @@ static CHARSET_INFO compiled_charsets[] = { my_strcasecmp_8bit, my_tosort_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3573,8 +3573,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif @@ -3608,8 +3608,8 @@ static CHARSET_INFO compiled_charsets[] = { my_tosort_8bit, my_strcasecmp_8bit, my_strncasecmp_8bit, - NULL, /* hash_caseup */ - NULL, /* hash_sort */ + my_hash_caseup_simple, + my_hash_sort_simple, 0 }, #endif |