Skip to content

Commit 59b51e6

Browse files
committed
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.
1 parent 3648b33 commit 59b51e6

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

sql/field.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9381,16 +9381,6 @@ String *Field_set::val_str(String *val_buffer,
93819381
ulonglong tmp=(ulonglong) Field_enum::val_int();
93829382
uint bitnr=0;
93839383

9384-
/*
9385-
Some callers expect *val_buffer to contain the result,
9386-
so we assign to it, rather than doing 'return &empty_set_string.
9387-
*/
9388-
*val_buffer= empty_set_string;
9389-
if (tmp == 0)
9390-
{
9391-
return val_buffer;
9392-
}
9393-
93949384
val_buffer->set_charset(field_charset());
93959385
val_buffer->length(0);
93969386

sql/field.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,8 +4809,7 @@ class Field_set final :public Field_enum {
48094809
const LEX_CSTRING *field_name_arg, uint32 packlength_arg,
48104810
const TYPELIB *typelib_arg, const DTCollation &collation)
48114811
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
4812-
field_name_arg, packlength_arg, typelib_arg, collation),
4813-
empty_set_string("", 0, collation.collation)
4812+
field_name_arg, packlength_arg, typelib_arg, collation)
48144813
{
48154814
flags=(flags & ~ENUM_FLAG) | SET_FLAG;
48164815
}
@@ -4833,8 +4832,6 @@ class Field_set final :public Field_enum {
48334832
{ return &type_handler_set; }
48344833
bool has_charset() const override { return true; }
48354834
Binlog_type_info binlog_type_info() const override;
4836-
private:
4837-
const String empty_set_string;
48384835
};
48394836

48404837

0 commit comments

Comments
 (0)