Skip to content

Commit

Permalink
types: avoid slicegrow in the FieldName.String() (#59136)
Browse files Browse the repository at this point in the history
close #59135
  • Loading branch information
hawkingrei authored Jan 23, 2025
1 parent c7e1799 commit 9c37399
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/types/field_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package types

import (
"strings"
"bytes"

"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/util/size"
Expand Down Expand Up @@ -43,10 +43,11 @@ const emptyName = "EMPTY_NAME"

// String implements Stringer interface.
func (name *FieldName) String() string {
builder := strings.Builder{}
if name.Hidden {
return emptyName
}
bs := make([]byte, 0, len(name.DBName.L)+1+len(name.TblName.L)+1+len(name.ColName.L))
builder := bytes.NewBuffer(bs)
if name.DBName.L != "" {
builder.WriteString(name.DBName.L + ".")
}
Expand Down

0 comments on commit 9c37399

Please sign in to comment.