Skip to content

Commit cffc85c

Browse files
author
Evil Puncker
authored
Reduced allocation on connection.go (#1421)
reduces allocations when there is only one param because current calculation is off by 2
1 parent aa0194d commit cffc85c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: connection.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (mc *mysqlConn) handleParams() (err error) {
6868
default:
6969
if cmdSet.Len() == 0 {
7070
// Heuristic: 29 chars for each other key=value to reduce reallocations
71-
cmdSet.Grow(4 + len(param) + 1 + len(val) + 30*(len(mc.cfg.Params)-1))
71+
cmdSet.Grow(4 + len(param) + 3 + len(val) + 30*(len(mc.cfg.Params)-1))
7272
cmdSet.WriteString("SET ")
7373
} else {
7474
cmdSet.WriteString(", ")

0 commit comments

Comments
 (0)