datum: remove wrong usage of pool and prealloc the buffer (#59331)

close pingcap/tidb#59332
This commit is contained in:
Weizhen Wang
2025-02-08 11:07:52 +08:00
committed by GitHub
parent f7759f56c0
commit 002a1a779b

View File

@ -23,7 +23,6 @@ import (
"sort"
"strconv"
"strings"
"sync"
"time"
"unicode/utf8"
"unsafe"
@ -2431,16 +2430,11 @@ func (ds *datumsSorter) Swap(i, j int) {
ds.datums[i], ds.datums[j] = ds.datums[j], ds.datums[i]
}
var strBuilderPool = sync.Pool{New: func() any { return &strings.Builder{} }}
// DatumsToString converts several datums to formatted string.
func DatumsToString(datums []Datum, handleSpecialValue bool) (string, error) {
n := len(datums)
builder := strBuilderPool.Get().(*strings.Builder)
defer func() {
builder.Reset()
strBuilderPool.Put(builder)
}()
builder := &strings.Builder{}
builder.Grow(8 * n)
if n > 1 {
builder.WriteString("(")
}