Skip to content

Commit 8751b72

Browse files
committed
buffer: rename take buffer funcs
1 parent 5975ca9 commit 8751b72

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

buffer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (b *buffer) readNext(need int) (p []byte, err error) {
8585
// If possible, a slice from the existing buffer is returned.
8686
// Otherwise a bigger buffer is made.
8787
// Only one buffer (total) can be used at a time.
88-
func (b *buffer) writeBuffer(length int) []byte {
88+
func (b *buffer) takeBuffer(length int) []byte {
8989
if b.length > 0 {
9090
return nil
9191
}
@@ -105,7 +105,7 @@ func (b *buffer) writeBuffer(length int) []byte {
105105
// shortcut which can be used if the requested buffer is guaranteed to be
106106
// smaller than defaultBufSize
107107
// Only one buffer (total) can be used at a time.
108-
func (b *buffer) smallWriteBuffer(length int) []byte {
108+
func (b *buffer) takeSmallBuffer(length int) []byte {
109109
if b.length == 0 {
110110
return b.buf[:length]
111111
}

packets.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
239239
}
240240

241241
// Calculate packet length and get buffer with that size
242-
data := mc.buf.smallWriteBuffer(pktLen + 4)
242+
data := mc.buf.takeSmallBuffer(pktLen + 4)
243243
if data == nil {
244244
// can not take the buffer. Something must be wrong with the connection
245245
errLog.Print("Busy buffer")
@@ -322,7 +322,7 @@ func (mc *mysqlConn) writeOldAuthPacket(cipher []byte) error {
322322

323323
// Calculate the packet lenght and add a tailing 0
324324
pktLen := len(scrambleBuff) + 1
325-
data := mc.buf.smallWriteBuffer(pktLen + 4)
325+
data := mc.buf.takeSmallBuffer(pktLen + 4)
326326
if data == nil {
327327
// can not take the buffer. Something must be wrong with the connection
328328
errLog.Print("Busy buffer")
@@ -349,7 +349,7 @@ func (mc *mysqlConn) writeCommandPacket(command byte) error {
349349
// Reset Packet Sequence
350350
mc.sequence = 0
351351

352-
data := mc.buf.smallWriteBuffer(4 + 1)
352+
data := mc.buf.takeSmallBuffer(4 + 1)
353353
if data == nil {
354354
// can not take the buffer. Something must be wrong with the connection
355355
errLog.Print("Busy buffer")
@@ -374,7 +374,7 @@ func (mc *mysqlConn) writeCommandPacketStr(command byte, arg string) error {
374374
mc.sequence = 0
375375

376376
pktLen := 1 + len(arg)
377-
data := mc.buf.writeBuffer(pktLen + 4)
377+
data := mc.buf.takeBuffer(pktLen + 4)
378378
if data == nil {
379379
// can not take the buffer. Something must be wrong with the connection
380380
errLog.Print("Busy buffer")
@@ -401,7 +401,7 @@ func (mc *mysqlConn) writeCommandPacketUint32(command byte, arg uint32) error {
401401
// Reset Packet Sequence
402402
mc.sequence = 0
403403

404-
data := mc.buf.smallWriteBuffer(4 + 1 + 4)
404+
data := mc.buf.takeSmallBuffer(4 + 1 + 4)
405405
if data == nil {
406406
// can not take the buffer. Something must be wrong with the connection
407407
errLog.Print("Busy buffer")
@@ -795,7 +795,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
795795

796796
if len(args) == 0 {
797797
const pktLen = 1 + 4 + 1 + 4
798-
data = mc.buf.writeBuffer(4 + pktLen)
798+
data = mc.buf.takeBuffer(4 + pktLen)
799799
if data == nil {
800800
// can not take the buffer. Something must be wrong with the connection
801801
errLog.Print("Busy buffer")

0 commit comments

Comments
 (0)