1
0
mirror of https://github.com/MariaDB/server.git synced 2025-04-23 07:05:53 +03:00

cleanup: Field_set::empty_set_string

in particular, it overwrites pre-allocated buffer in val_buffer,
so following val_buffer->append()'s cause totally unnecessary
mallocs.
This commit is contained in:
Sergei Golubchik 2020-10-02 00:03:20 +02:00
parent 3648b333c7
commit 59b51e6aa7
2 changed files with 1 additions and 14 deletions

View File

@ -9381,16 +9381,6 @@ String *Field_set::val_str(String *val_buffer,
ulonglong tmp=(ulonglong) Field_enum::val_int(); ulonglong tmp=(ulonglong) Field_enum::val_int();
uint bitnr=0; uint bitnr=0;
/*
Some callers expect *val_buffer to contain the result,
so we assign to it, rather than doing 'return &empty_set_string.
*/
*val_buffer= empty_set_string;
if (tmp == 0)
{
return val_buffer;
}
val_buffer->set_charset(field_charset()); val_buffer->set_charset(field_charset());
val_buffer->length(0); val_buffer->length(0);

View File

@ -4809,8 +4809,7 @@ public:
const LEX_CSTRING *field_name_arg, uint32 packlength_arg, const LEX_CSTRING *field_name_arg, uint32 packlength_arg,
const TYPELIB *typelib_arg, const DTCollation &collation) const TYPELIB *typelib_arg, const DTCollation &collation)
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, packlength_arg, typelib_arg, collation), field_name_arg, packlength_arg, typelib_arg, collation)
empty_set_string("", 0, collation.collation)
{ {
flags=(flags & ~ENUM_FLAG) | SET_FLAG; flags=(flags & ~ENUM_FLAG) | SET_FLAG;
} }
@ -4833,8 +4832,6 @@ public:
{ return &type_handler_set; } { return &type_handler_set; }
bool has_charset() const override { return true; } bool has_charset() const override { return true; }
Binlog_type_info binlog_type_info() const override; Binlog_type_info binlog_type_info() const override;
private:
const String empty_set_string;
}; };