Skip to content

Commit 8de9cd6

Browse files
committed
more simplify
1 parent 3fe8d5c commit 8de9cd6

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

buffer.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,8 @@ func (b *buffer) takeCompleteBuffer() ([]byte, error) {
150150
}
151151

152152
// store stores buf, an updated buffer, if its suitable to do so.
153-
func (b *buffer) store(buf []byte) error {
154-
if b.busy() {
155-
return ErrBusyBuffer
156-
} else if cap(buf) <= maxCachedBufSize && cap(buf) > cap(b.cachedBuf) {
153+
func (b *buffer) store(buf []byte) {
154+
if cap(buf) <= maxCachedBufSize && cap(buf) > cap(b.cachedBuf) {
157155
b.cachedBuf = buf[:cap(buf)]
158156
}
159-
return nil
160157
}

packets.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
11911191
// In that case we must build the data packet with the new values buffer
11921192
if valuesCap != cap(paramValues) {
11931193
data = append(data[:pos], paramValues...)
1194-
if err = mc.buf.store(data); err != nil {
1195-
return err
1196-
}
1194+
mc.buf.store(data) // allow this buffer to be reused
11971195
}
11981196

11991197
pos += len(paramValues)

0 commit comments

Comments
 (0)