Skip to content

Commit

Permalink
more simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Nov 23, 2024
1 parent 3fe8d5c commit 8de9cd6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 2 additions & 5 deletions buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,8 @@ func (b *buffer) takeCompleteBuffer() ([]byte, error) {
}

// store stores buf, an updated buffer, if its suitable to do so.
func (b *buffer) store(buf []byte) error {
if b.busy() {
return ErrBusyBuffer
} else if cap(buf) <= maxCachedBufSize && cap(buf) > cap(b.cachedBuf) {
func (b *buffer) store(buf []byte) {
if cap(buf) <= maxCachedBufSize && cap(buf) > cap(b.cachedBuf) {
b.cachedBuf = buf[:cap(buf)]
}
return nil
}
4 changes: 1 addition & 3 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
// In that case we must build the data packet with the new values buffer
if valuesCap != cap(paramValues) {
data = append(data[:pos], paramValues...)
if err = mc.buf.store(data); err != nil {
return err
}
mc.buf.store(data) // allow this buffer to be reused
}

pos += len(paramValues)
Expand Down

0 comments on commit 8de9cd6

Please sign in to comment.