From 61c15ebe323d4d6f02fab86c405b2613e5784961 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 16 Jul 2020 16:30:06 +0300 Subject: Remove String::lex_string() and String::lex_cstring() - Better to use 'String *' directly. - Added String::get_value(LEX_STRING*) for the few cases where we want to convert a String to LEX_CSTRING. Other things: - Use StringBuffer for some functions to avoid mallocs --- sql/sql_string.h | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'sql/sql_string.h') diff --git a/sql/sql_string.h b/sql/sql_string.h index 2d38f6d5d13..274b1d9a5df 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -222,18 +222,6 @@ public: inline bool is_empty() const { return (str_length == 0); } inline const char *ptr() const { return Ptr; } inline const char *end() const { return Ptr + str_length; } - - LEX_STRING lex_string() const - { - LEX_STRING str = { (char*) ptr(), length() }; - return str; - } - LEX_CSTRING lex_cstring() const - { - LEX_CSTRING skr = { ptr(), length() }; - return skr; - } - bool has_8bit_bytes() const { for (const char *c= ptr(), *c_end= end(); c < c_end; c++) @@ -488,6 +476,12 @@ public: if (str.Alloced_length) Alloced_length= (uint32) (str.Alloced_length - offset); } + inline LEX_CSTRING *get_value(LEX_CSTRING *res) + { + res->str= Ptr; + res->length= str_length; + return res; + } /* Take over handling of buffer from some other object */ void reset(char *ptr_arg, size_t length_arg, size_t alloced_length_arg) @@ -888,13 +882,13 @@ public: { return Binary_string::append_hex((const char*)src, srclen); } - bool append_introducer_and_hex(CHARSET_INFO *cs, const LEX_CSTRING &str) + bool append_introducer_and_hex(String *str) { return append(STRING_WITH_LEN("_")) || - append(cs->csname) || + append(str->charset()->csname) || append(STRING_WITH_LEN(" 0x")) || - append_hex(str.str, (uint32) str.length); + append_hex(str->ptr(), (uint32) str->length()); } bool append(IO_CACHE* file, uint32 arg_length) { -- cgit v1.2.1