Commit b3bf99ed authored by unknown's avatar unknown

some optimization in append_identifier (sql/sql_show.cc)


sql/sql_show.cc:
  some optimization in append_identifier
parent dfbaa161
...@@ -1086,7 +1086,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) ...@@ -1086,7 +1086,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
static bool require_quotes(const char *name, uint length) static inline const char *require_quotes(const char *name, uint length)
{ {
uint i, d, c; uint i, d, c;
for (i=0; i<length; i+=d) for (i=0; i<length; i+=d)
...@@ -1094,7 +1094,7 @@ static bool require_quotes(const char *name, uint length) ...@@ -1094,7 +1094,7 @@ static bool require_quotes(const char *name, uint length)
c=((uchar *)name)[i]; c=((uchar *)name)[i];
d=my_mbcharlen(system_charset_info, c); d=my_mbcharlen(system_charset_info, c);
if (d==1 && !system_charset_info->ident_map[c]) if (d==1 && !system_charset_info->ident_map[c])
return 1; return name+i;
} }
return 0; return 0;
} }
...@@ -1113,7 +1113,8 @@ static bool require_quotes(const char *name, uint length) ...@@ -1113,7 +1113,8 @@ static bool require_quotes(const char *name, uint length)
0 string doesn't contain required char 0 string doesn't contain required char
*/ */
static const char *look_for_char(const char *name, uint length, char q) static inline const char *look_for_char(const char *name,
uint length, char q)
{ {
const char *cur= name; const char *cur= name;
const char *end= cur+length; const char *end= cur+length;
...@@ -1141,27 +1142,29 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) ...@@ -1141,27 +1142,29 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
if (is_keyword(name,length)) if (is_keyword(name,length))
{ {
packet->append(&qtype, 1); packet->append(&qtype, 1, system_charset_info);
packet->append(name, length, system_charset_info); packet->append(name, length, system_charset_info);
packet->append(&qtype, 1); packet->append(&qtype, 1, system_charset_info);
} }
else else
{ {
if (!require_quotes(name, length)) if (!(qplace= require_quotes(name, length)))
{ {
if (!(thd->options & OPTION_QUOTE_SHOW_CREATE)) if (!(thd->options & OPTION_QUOTE_SHOW_CREATE))
packet->append(name, length, system_charset_info); packet->append(name, length, system_charset_info);
else else
{ {
packet->append(&qtype, 1); packet->append(&qtype, 1, system_charset_info);
packet->append(name, length, system_charset_info); packet->append(name, length, system_charset_info);
packet->append(&qtype, 1); packet->append(&qtype, 1, system_charset_info);
} }
} }
else else
{ {
packet->append(&qtype, 1); packet->shrink(packet->length()+length+2);
qplace= look_for_char(name,length,qtype); packet->append(&qtype, 1, system_charset_info);
if (*qplace != qtype)
qplace= look_for_char(qplace+1,length-(qplace-name)-1,qtype);
while (qplace) while (qplace)
{ {
if ((part_len= qplace-name)) if ((part_len= qplace-name))
...@@ -1174,7 +1177,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) ...@@ -1174,7 +1177,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
qplace= look_for_char(name+1,length-1,qtype); qplace= look_for_char(name+1,length-1,qtype);
} }
packet->append(name, length, system_charset_info); packet->append(name, length, system_charset_info);
packet->append(&qtype, 1); packet->append(&qtype, 1, system_charset_info);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment