summaryrefslogtreecommitdiff
path: root/sql/lex_string.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-04-30 14:24:48 +0300
committerMonty <monty@mariadb.org>2018-04-30 14:24:48 +0300
commit7d6b55b99aa11bc888bdf7ad1ccdf845909a91c5 (patch)
treecdd6983b0a7196b8b995076f71aa5d3d2062194a /sql/lex_string.h
parent862e602b5a5bbc79bacdac9722f1ab69d0ccf7c3 (diff)
downloadmariadb-git-7d6b55b99aa11bc888bdf7ad1ccdf845909a91c5.tar.gz
Added version of lex_string_eq that compares with const char *
Change all my_stcasecmp() calls that uses lexical keywords to use lex_string_eq. This is faster as we only call strcasecmp() for strings of different lengths. Removed not used function lex_string_syseq()
Diffstat (limited to 'sql/lex_string.h')
-rw-r--r--sql/lex_string.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/lex_string.h b/sql/lex_string.h
index 25f2c83a372..a5209165be0 100644
--- a/sql/lex_string.h
+++ b/sql/lex_string.h
@@ -21,6 +21,7 @@
typedef struct st_mysql_const_lex_string LEX_CSTRING;
/* Functions to compare if two lex strings are equal */
+
static inline bool lex_string_cmp(CHARSET_INFO *charset, const LEX_CSTRING *a,
const LEX_CSTRING *b)
{
@@ -30,6 +31,7 @@ static inline bool lex_string_cmp(CHARSET_INFO *charset, const LEX_CSTRING *a,
/*
Compare to LEX_CSTRING's and return 0 if equal
*/
+
static inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
{
return (a->length != b->length ||
@@ -40,6 +42,7 @@ static inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
Compare if two LEX_CSTRING are equal. Assumption is that
character set is ASCII (like for plugin names)
*/
+
static inline bool lex_string_eq(const LEX_CSTRING *a, const LEX_CSTRING *b)
{
if (a->length != b->length)
@@ -48,12 +51,15 @@ static inline bool lex_string_eq(const LEX_CSTRING *a, const LEX_CSTRING *b)
}
/*
- Compare if two LEX_CSTRING are equal in system character set
- (field names, user variables, etc - but *not* table names)
+ To be used when calling lex_string_eq with STRING_WITH_LEN() as second
+ argument
*/
-static inline bool lex_string_syseq(const LEX_CSTRING *a, const LEX_CSTRING *b)
+
+static inline bool lex_string_eq(const LEX_CSTRING *a, const char *b, size_t b_length)
{
- return lex_string_cmp(system_charset_info, a, b) == 0;
+ if (a->length != b_length)
+ return 0; /* Different */
+ return strcasecmp(a->str, b) == 0;
}
#endif /* LEX_STRING_INCLUDED */