From f7fd5811bb231a88abf2df2f09eba37a7e8db1a8 Mon Sep 17 00:00:00 2001 From: Evil Puncker Date: Tue, 25 Apr 2023 12:12:11 -0300 Subject: [PATCH] Reduced allocation on connection.go reduces allocations when there is only one param because current calculation is off by 2 --- connection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 947a883e3..0aeef207b 100644 --- a/connection.go +++ b/connection.go @@ -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(", ")