summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2002-08-15 16:42:54 +0500
committerunknown <bar@bar.mysql.r18.ru>2002-08-15 16:42:54 +0500
commitbf5b046e841121c4250bd668449df99302de31ea (patch)
tree0771a890e5d8ed36e182ce6069988f32b9db0bc7 /strings
parent6cc0d7d7e8d8321ecd2d918cb0e3160eb0322ecd (diff)
downloadmariadb-git-bf5b046e841121c4250bd668449df99302de31ea.tar.gz
Some speed improvements
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-mb.c24
-rw-r--r--strings/ctype-simple.c20
2 files changed, 31 insertions, 13 deletions
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index d328ebb7a36..aa475e281d0 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -24,13 +24,15 @@ void my_caseup_str_mb(CHARSET_INFO * cs, char *str)
{
register uint32 l;
register char *end=str+strlen(str); /* BAR TODO: remove strlen() call */
+ register uchar *map=cs->to_upper;
+
while (*str)
{
if ((l=my_ismbchar(cs, str,end)))
str+=l;
else
{
- *str=(char)my_toupper(cs,(uchar)*str);
+ *str=(char) map[(uchar)*str];
str++;
}
}
@@ -40,13 +42,15 @@ void my_casedn_str_mb(CHARSET_INFO * cs, char *str)
{
register uint32 l;
register char *end=str+strlen(str);
+ register uchar *map=cs->to_lower;
+
while (*str)
{
if ((l=my_ismbchar(cs, str,end)))
str+=l;
else
{
- *str=(char)my_tolower(cs,(uchar)*str);
+ *str=(char) map[(uchar)*str];
str++;
}
}
@@ -56,13 +60,15 @@ void my_caseup_mb(CHARSET_INFO * cs, char *str, uint length)
{
register uint32 l;
register char *end=str+length;
+ register uchar *map=cs->to_upper;
+
while (str<end)
{
if ((l=my_ismbchar(cs, str,end)))
str+=l;
else
{
- *str=(char)my_toupper(cs,(uchar)*str);
+ *str=(char) map[(uchar)*str];
str++;
}
}
@@ -72,13 +78,15 @@ void my_casedn_mb(CHARSET_INFO * cs, char *str, uint length)
{
register uint32 l;
register char *end=str+length;
+ register uchar *map=cs->to_lower;
+
while (str<end)
{
if ((l=my_ismbchar(cs, str,end)))
str+=l;
else
{
- *str=(char)my_tolower(cs,(uchar)*str);
+ *str=(char) map[(uchar)*str];
str++;
}
}
@@ -88,6 +96,8 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t)
{
register uint32 l;
register const char *end=s+strlen(s);
+ register uchar *map=cs->to_upper;
+
while (s<end)
{
if ((l=my_ismbchar(cs, s,end)))
@@ -98,7 +108,7 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t)
}
else if (my_ismbhead(cs, *t))
return 1;
- else if (my_toupper(cs,(uchar) *s++) != my_toupper(cs,(uchar) *t++))
+ else if (map[(uchar) *s++] != map[(uchar) *t++])
return 1;
}
return *t;
@@ -110,6 +120,8 @@ int my_strncasecmp_mb(CHARSET_INFO * cs,
{
register uint32 l;
register const char *end=s+len;
+ register uchar *map=cs->to_upper;
+
while (s<end)
{
if ((l=my_ismbchar(cs, s,end)))
@@ -120,7 +132,7 @@ int my_strncasecmp_mb(CHARSET_INFO * cs,
}
else if (my_ismbhead(cs, *t))
return 1;
- else if (my_toupper(cs,(uchar) *s++) != my_toupper(cs,(uchar) *t++))
+ else if (map[(uchar) *s++] != map[(uchar) *t++])
return 1;
}
return 0;
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 52c66f0ad4e..19989afea60 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -46,43 +46,49 @@ int my_strnncoll_simple(CHARSET_INFO * cs,const char *s, uint slen,
void my_caseup_str_8bit(CHARSET_INFO * cs,char *str)
{
- while ((*str = (char) my_toupper(cs,(uchar) *str)) != 0)
+ register uchar *map=cs->to_upper;
+ while ((*str = (char) map[(uchar) *str]) != 0)
str++;
}
void my_casedn_str_8bit(CHARSET_INFO * cs,char *str)
{
- while ((*str = (char) my_tolower(cs,(uchar)*str)) != 0)
+ register uchar *map=cs->to_lower;
+ while ((*str = (char) map[(uchar)*str]) != 0)
str++;
}
void my_caseup_8bit(CHARSET_INFO * cs, char *str, uint length)
{
+ register uchar *map=cs->to_upper;
for ( ; length>0 ; length--, str++)
- *str= (char) my_toupper(cs,(uchar)*str);
+ *str= (char) map[(uchar)*str];
}
void my_casedn_8bit(CHARSET_INFO * cs, char *str, uint length)
{
+ register uchar *map=cs->to_lower;
for ( ; length>0 ; length--, str++)
- *str= (char)my_tolower(cs,(uchar) *str);
+ *str= (char) map[(uchar) *str];
}
int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t)
{
- while (my_toupper(cs,(uchar) *s) == my_toupper(cs,(uchar) *t++))
+ register uchar *map=cs->to_upper;
+ while (map[(uchar) *s] == map[(uchar) *t++])
if (!*s++) return 0;
- return ((int) my_toupper(cs,(uchar) s[0]) - (int) my_toupper(cs,(uchar) t[-1]));
+ return ((int) map[(uchar) s[0]] - (int) map[(uchar) t[-1]]);
}
int my_strncasecmp_8bit(CHARSET_INFO * cs,
const char *s, const char *t, uint len)
{
- while (len-- != 0 && my_toupper(cs,(uchar)*s++) == my_toupper(cs,(uchar)*t++)) ;
+ register uchar *map=cs->to_upper;
+ while (len-- != 0 && map[(uchar)*s++] == map[(uchar)*t++]) ;
return (int) len+1;
}