summaryrefslogtreecommitdiff
path: root/source3/lib/util_str.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-11 09:56:38 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-11 09:56:38 +0000
commit714518e550f3c6ee36fa6e3e2447b943898a2ac5 (patch)
treebf01343fb92861e3d2ec9a55e9550a7f08dd1493 /source3/lib/util_str.c
parent60fd2ec8cc37d5af323235bf750d41dba52c0c92 (diff)
downloadsamba-714518e550f3c6ee36fa6e3e2447b943898a2ac5.tar.gz
samba-714518e550f3c6ee36fa6e3e2447b943898a2ac5.tar.bz2
samba-714518e550f3c6ee36fa6e3e2447b943898a2ac5.zip
this adds a completely new hash based mangling scheme
the hash for this scheme is *much* larger (approximately 31 bits) and the code is written to be very fast, correctly handling multibyte while not doing any actual multi-byte conversions in the vast majority of cases you can select this scheme using "mangling method = hash2", although I may make it the default if it works out well. (This used to be commit bb173c1a7e2408ced967ebac40b5e3f852ccd3a1)
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r--source3/lib/util_str.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 200f4ce696..e3dd3124a5 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -900,6 +900,16 @@ char *strrchr_m(const char *s, char c)
********************************************************************/
void strlower_m(char *s)
{
+ /* this is quite a common operation, so we want it to be
+ fast. We optimise for the ascii case, knowing that all our
+ supported multi-byte character sets are ascii-compatible
+ (ie. they match for the first 128 chars) */
+ while (*s && !(((unsigned char)s[0]) & 0x7F)) {
+ *s++ = tolower((unsigned char)*s);
+ }
+
+ if (!*s) return;
+
/* I assume that lowercased string takes the same number of bytes
* as source string even in UTF-8 encoding. (VIV) */
unix_strlower(s,strlen(s)+1,s,strlen(s)+1);
@@ -910,6 +920,16 @@ void strlower_m(char *s)
********************************************************************/
void strupper_m(char *s)
{
+ /* this is quite a common operation, so we want it to be
+ fast. We optimise for the ascii case, knowing that all our
+ supported multi-byte character sets are ascii-compatible
+ (ie. they match for the first 128 chars) */
+ while (*s && !(((unsigned char)s[0]) & 0x7F)) {
+ *s++ = toupper((unsigned char)*s);
+ }
+
+ if (!*s) return;
+
/* I assume that lowercased string takes the same number of bytes
* as source string even in multibyte encoding. (VIV) */
unix_strupper(s,strlen(s)+1,s,strlen(s)+1);