summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorunknown <vva@eagle.mysql.r18.ru>2004-02-13 00:28:00 +0400
committerunknown <vva@eagle.mysql.r18.ru>2004-02-13 00:28:00 +0400
commitb3bf99ed42f6ae344cb646ea421ccba7fbaee69f (patch)
treed8475af757157d102e0b08554f57a8685449d115 /sql/sql_show.cc
parentdfbaa16160a82b7e70603ba89e76804ba771b7e1 (diff)
downloadmariadb-git-b3bf99ed42f6ae344cb646ea421ccba7fbaee69f.tar.gz
some optimization in append_identifier (sql/sql_show.cc)
sql/sql_show.cc: some optimization in append_identifier
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 5870e58d9a4..2d7b89a24a1 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1086,7 +1086,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
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;
for (i=0; i<length; i+=d)
@@ -1094,7 +1094,7 @@ static bool require_quotes(const char *name, uint length)
c=((uchar *)name)[i];
d=my_mbcharlen(system_charset_info, c);
if (d==1 && !system_charset_info->ident_map[c])
- return 1;
+ return name+i;
}
return 0;
}
@@ -1113,7 +1113,8 @@ static bool require_quotes(const char *name, uint length)
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 *end= cur+length;
@@ -1141,27 +1142,29 @@ append_identifier(THD *thd, String *packet, const char *name, uint 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(&qtype, 1);
+ packet->append(&qtype, 1, system_charset_info);
}
else
{
- if (!require_quotes(name, length))
+ if (!(qplace= require_quotes(name, length)))
{
if (!(thd->options & OPTION_QUOTE_SHOW_CREATE))
packet->append(name, length, system_charset_info);
else
{
- packet->append(&qtype, 1);
+ packet->append(&qtype, 1, system_charset_info);
packet->append(name, length, system_charset_info);
- packet->append(&qtype, 1);
+ packet->append(&qtype, 1, system_charset_info);
}
}
else
{
- packet->append(&qtype, 1);
- qplace= look_for_char(name,length,qtype);
+ packet->shrink(packet->length()+length+2);
+ packet->append(&qtype, 1, system_charset_info);
+ if (*qplace != qtype)
+ qplace= look_for_char(qplace+1,length-(qplace-name)-1,qtype);
while (qplace)
{
if ((part_len= qplace-name))
@@ -1174,7 +1177,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
qplace= look_for_char(name+1,length-1,qtype);
}
packet->append(name, length, system_charset_info);
- packet->append(&qtype, 1);
+ packet->append(&qtype, 1, system_charset_info);
}
}
}