diff options
author | Monty <monty@mariadb.org> | 2020-07-16 12:23:37 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-07-23 10:54:32 +0300 |
commit | c89e927a5675bd1e84a9c5dd02f5d649e829453e (patch) | |
tree | 2a5eb36bc2be14b89a964f65c42701335fdabb3f | |
parent | 5e76e234f5e1821fda291cef4cc77d3ecb4dfcfc (diff) | |
download | mariadb-git-c89e927a5675bd1e84a9c5dd02f5d649e829453e.tar.gz |
Clean up Item_uint() & Item_int()
- Removed val_str() and print() as these are handled by Item_int()
- Use local StringBuffer for Item_int::print() to avoid mallocs
-rw-r--r-- | include/my_global.h | 2 | ||||
-rw-r--r-- | sql/item.cc | 20 | ||||
-rw-r--r-- | sql/item.h | 2 |
3 files changed, 5 insertions, 19 deletions
diff --git a/include/my_global.h b/include/my_global.h index 5d80b3881d4..86ef5f882f6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -796,6 +796,8 @@ inline unsigned long long my_double2ulonglong(double d) #define LONGLONG_MIN ((long long) 0x8000000000000000LL) #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) #endif +/* Max length needed for a buffer to hold a longlong or ulonglong + end \0 */ +#define LONGLONG_BUFFER_SIZE 21 #if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX) /* First check for ANSI C99 definition: */ diff --git a/sql/item.cc b/sql/item.cc index 6f34c93e21c..ca23fddff34 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3626,9 +3626,10 @@ String *Item_int::val_str(String *str) void Item_int::print(String *str, enum_query_type query_type) { + StringBuffer<LONGLONG_BUFFER_SIZE> buf; // my_charset_bin is good enough for numbers - str_value.set_int(value, unsigned_flag, &my_charset_bin); - str->append(str_value); + buf.set_int(value, unsigned_flag, &my_charset_bin); + str->append(buf); } @@ -3654,21 +3655,6 @@ Item_uint::Item_uint(THD *thd, const char *str_arg, longlong i, uint length): } -String *Item_uint::val_str(String *str) -{ - str->set((ulonglong) value, collation.collation); - return str; -} - - -void Item_uint::print(String *str, enum_query_type query_type) -{ - // latin1 is good enough for numbers - str_value.set((ulonglong) value, default_charset()); - str->append(str_value); -} - - Item_decimal::Item_decimal(THD *thd, const char *str_arg, size_t length, CHARSET_INFO *charset): Item_num(thd) diff --git a/sql/item.h b/sql/item.h index 20dc1474bf9..71d7549f72f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4238,9 +4238,7 @@ public: Item_uint(THD *thd, ulonglong i): Item_int(thd, i, 10) {} Item_uint(THD *thd, const char *str_arg, longlong i, uint length); double val_real() { return ulonglong2double((ulonglong)value); } - String *val_str(String*); Item *clone_item(THD *thd); - virtual void print(String *str, enum_query_type query_type); Item *neg(THD *thd); uint decimal_precision() const { return max_length; } Item *get_copy(THD *thd) |