Skip to content

Commit

Permalink
cleanup: Field_set::empty_set_string
Browse files Browse the repository at this point in the history
in particular, it overwrites pre-allocated buffer in val_buffer,
so following val_buffer->append()'s cause totally unnecessary
mallocs.
  • Loading branch information
vuvova committed Jun 11, 2021
1 parent 3648b33 commit 59b51e6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
10 changes: 0 additions & 10 deletions sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9381,16 +9381,6 @@ String *Field_set::val_str(String *val_buffer,
ulonglong tmp=(ulonglong) Field_enum::val_int();
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->length(0);

Expand Down
5 changes: 1 addition & 4 deletions sql/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -4809,8 +4809,7 @@ class Field_set final :public Field_enum {
const LEX_CSTRING *field_name_arg, uint32 packlength_arg,
const TYPELIB *typelib_arg, const DTCollation &collation)
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, packlength_arg, typelib_arg, collation),
empty_set_string("", 0, collation.collation)
field_name_arg, packlength_arg, typelib_arg, collation)
{
flags=(flags & ~ENUM_FLAG) | SET_FLAG;
}
Expand All @@ -4833,8 +4832,6 @@ class Field_set final :public Field_enum {
{ return &type_handler_set; }
bool has_charset() const override { return true; }
Binlog_type_info binlog_type_info() const override;
private:
const String empty_set_string;
};


Expand Down

0 comments on commit 59b51e6

Please sign in to comment.