summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorbar@deer.(none) <>2004-06-18 11:00:51 +0500
committerbar@deer.(none) <>2004-06-18 11:00:51 +0500
commit92833475e7f6543b6b4de17d715095a0e02ebcad (patch)
treec10c62162d3b941e40be99f517079c9c60a6b6df /strings
parentefc2936e5ebc4725d9c6e0fded03efd95e13e413 (diff)
downloadmariadb-git-92833475e7f6543b6b4de17d715095a0e02ebcad.tar.gz
ctype-uca.c:
Code optimization to make it look better and work faster.
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-uca.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index 224c3db0f28..a388e0cb2a2 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -7473,55 +7473,62 @@ static int ch2x(int ch)
static my_coll_lexem_num my_coll_lexem_next(MY_COLL_LEXEM *lexem)
{
- for ( ;lexem->beg < lexem->end ; lexem->beg++)
+ const char *beg;
+ my_coll_lexem_num rc;
+
+ for (beg= lexem->beg ; beg < lexem->end ; beg++)
{
- lexem->prev= lexem->beg;
- if (lexem->beg[0] == ' ' || lexem->beg[0] == '\t' ||
- lexem->beg[0] == '\r' || lexem->beg[0] == '\n')
+ if (*beg == ' ' || *beg == '\t' || *beg == '\r' || *beg == '\n')
continue;
- if (lexem->beg[0] == '&')
+ if (*beg == '&')
{
- lexem->beg++;
- return MY_COLL_LEXEM_SHIFT;
+ beg++;
+ rc= MY_COLL_LEXEM_SHIFT;
+ goto ex;
}
- if (lexem->beg[0] == '<')
+ if (beg[0] == '<')
{
- for (lexem->beg++, lexem->diff=1;
- (lexem->beg < lexem->end) &&
- (lexem->beg[0] == '<') && (lexem->diff<3);
- lexem->beg++, lexem->diff++);
- return MY_COLL_LEXEM_DIFF;
+ for (beg++, lexem->diff= 1;
+ (beg < lexem->end) &&
+ (*beg == '<') && (lexem->diff<3);
+ beg++, lexem->diff++);
+ rc= MY_COLL_LEXEM_DIFF;
+ goto ex;
}
- if ((lexem->beg[0] >= 'a' && lexem->beg[0] <= 'z') ||
- (lexem->beg[0] >= 'A' && lexem->beg[0] <= 'Z'))
+ if ((*beg >= 'a' && *beg <= 'z') || (*beg >= 'A' && *beg <= 'Z'))
{
- lexem->code= lexem->beg[0];
- lexem->beg++;
- return MY_COLL_LEXEM_CHAR;
+ lexem->code= *beg++;
+ rc= MY_COLL_LEXEM_CHAR;
+ goto ex;
}
- if ((lexem->beg[0] == '\\') &&
- (lexem->beg+2 < lexem->end) &&
- (lexem->beg[1] == 'u'))
+ if ((*beg == '\\') && (beg+2 < lexem->end) && (beg[1] == 'u'))
{
int ch;
+ beg+= 2;
lexem->code= 0;
- for (lexem->beg+=2;
- (lexem->beg < lexem->end) && ((ch= ch2x(lexem->beg[0])) >= 0) ;
- lexem->beg++)
- {
+ while ((beg < lexem->end) && ((ch= ch2x(beg[0])) >= 0))
+ {
lexem->code= (lexem->code << 4) + ch;
+ beg++;
}
- return MY_COLL_LEXEM_CHAR;
+ rc= MY_COLL_LEXEM_CHAR;
+ goto ex;
}
- return MY_COLL_LEXEM_ERROR;
+ rc= MY_COLL_LEXEM_ERROR;
+ goto ex;
}
- return MY_COLL_LEXEM_EOF;
+ rc= MY_COLL_LEXEM_EOF;
+
+ex:
+ lexem->prev= lexem->beg;
+ lexem->beg= beg;
+ return rc;
}