Skip to content

Commit

Permalink
Reduced allocation on connection.go (#1421)
Browse files Browse the repository at this point in the history
reduces allocations when there is only one param because current calculation is off by 2
  • Loading branch information
EPuncker committed Apr 25, 2023
1 parent aa0194d commit cffc85c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (mc *mysqlConn) handleParams() (err error) {
default:
if cmdSet.Len() == 0 {
// Heuristic: 29 chars for each other key=value to reduce reallocations
cmdSet.Grow(4 + len(param) + 1 + len(val) + 30*(len(mc.cfg.Params)-1))
cmdSet.Grow(4 + len(param) + 3 + len(val) + 30*(len(mc.cfg.Params)-1))
cmdSet.WriteString("SET ")
} else {
cmdSet.WriteString(", ")
Expand Down

0 comments on commit cffc85c

Please sign in to comment.