summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-01-30 22:29:55 +0100
committerSergei Golubchik <serg@mariadb.org>2018-02-12 13:35:11 +0100
commitf894f902a41ecbd7477ef821cebc70f288aea060 (patch)
tree41b663a62fef920ee63216a700162067def2fada
parent711f3dd7f5ba2f21fd4f0a42b4bf9fa811d043cf (diff)
downloadmariadb-git-f894f902a41ecbd7477ef821cebc70f288aea060.tar.gz
cleanup: TABLE::find_field_by_name
use name hash, just like find_field_in_table() does
-rw-r--r--sql/table.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 1e3e5189739..dee8c815c19 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -8938,12 +8938,21 @@ void vers_select_conds_t::resolve_units(bool timestamps_only)
Field *TABLE::find_field_by_name(LEX_CSTRING *str) const
{
+ Field **tmp;
size_t length= str->length;
- for (Field **tmp= field; *tmp; tmp++)
+ if (s->name_hash.records)
{
- if ((*tmp)->field_name.length == length &&
- !lex_string_cmp(system_charset_info, &(*tmp)->field_name, str))
- return *tmp;
+ tmp= (Field**) my_hash_search(&s->name_hash, (uchar*) str->str, length);
+ return tmp ? field[tmp - s->field] : NULL;
+ }
+ else
+ {
+ for (tmp= field; *tmp; tmp++)
+ {
+ if ((*tmp)->field_name.length == length &&
+ !lex_string_cmp(system_charset_info, &(*tmp)->field_name, str))
+ return *tmp;
+ }
}
return NULL;
}