Skip to content

Commit 9f84dfb

Browse files
committed
Remove one more allocation
benchmark old ns/op new ns/op delta BenchmarkInterpolation 2209 2116 -4.21% benchmark old allocs new allocs delta BenchmarkInterpolation 4 3 -25.00% benchmark old bytes new bytes delta BenchmarkInterpolation 496 464 -6.45%
1 parent 0b75396 commit 9f84dfb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

connection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
210210
buf := make([]byte, 0, estimated)
211211
argPos := 0
212212

213-
// Go 1.5 will optimize range([]byte(string)) to skip allocation.
214-
for _, c := range []byte(query) {
213+
for i := 0; i < len(query); i++ {
214+
c := query[i]
215215
if c != '?' {
216216
buf = append(buf, c)
217217
continue

0 commit comments

Comments
 (0)