Pārlūkot izejas kodu

buffer: rename take buffer funcs

Julien Schmidt 12 gadi atpakaļ
vecāks
revīzija
8751b72867
2 mainītis faili ar 8 papildinājumiem un 8 dzēšanām
  1. 2 2
      buffer.go
  2. 6 6
      packets.go

+ 2 - 2
buffer.go

@@ -85,7 +85,7 @@ func (b *buffer) readNext(need int) (p []byte, err error) {
 // If possible, a slice from the existing buffer is returned.
 // Otherwise a bigger buffer is made.
 // Only one buffer (total) can be used at a time.
-func (b *buffer) writeBuffer(length int) []byte {
+func (b *buffer) takeBuffer(length int) []byte {
 	if b.length > 0 {
 		return nil
 	}
@@ -105,7 +105,7 @@ func (b *buffer) writeBuffer(length int) []byte {
 // shortcut which can be used if the requested buffer is guaranteed to be
 // smaller than defaultBufSize
 // Only one buffer (total) can be used at a time.
-func (b *buffer) smallWriteBuffer(length int) []byte {
+func (b *buffer) takeSmallBuffer(length int) []byte {
 	if b.length == 0 {
 		return b.buf[:length]
 	}

+ 6 - 6
packets.go

@@ -239,7 +239,7 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
 	}
 
 	// Calculate packet length and get buffer with that size
-	data := mc.buf.smallWriteBuffer(pktLen + 4)
+	data := mc.buf.takeSmallBuffer(pktLen + 4)
 	if data == nil {
 		// can not take the buffer. Something must be wrong with the connection
 		errLog.Print("Busy buffer")
@@ -322,7 +322,7 @@ func (mc *mysqlConn) writeOldAuthPacket(cipher []byte) error {
 
 	// Calculate the packet lenght and add a tailing 0
 	pktLen := len(scrambleBuff) + 1
-	data := mc.buf.smallWriteBuffer(pktLen + 4)
+	data := mc.buf.takeSmallBuffer(pktLen + 4)
 	if data == nil {
 		// can not take the buffer. Something must be wrong with the connection
 		errLog.Print("Busy buffer")
@@ -349,7 +349,7 @@ func (mc *mysqlConn) writeCommandPacket(command byte) error {
 	// Reset Packet Sequence
 	mc.sequence = 0
 
-	data := mc.buf.smallWriteBuffer(4 + 1)
+	data := mc.buf.takeSmallBuffer(4 + 1)
 	if data == nil {
 		// can not take the buffer. Something must be wrong with the connection
 		errLog.Print("Busy buffer")
@@ -374,7 +374,7 @@ func (mc *mysqlConn) writeCommandPacketStr(command byte, arg string) error {
 	mc.sequence = 0
 
 	pktLen := 1 + len(arg)
-	data := mc.buf.writeBuffer(pktLen + 4)
+	data := mc.buf.takeBuffer(pktLen + 4)
 	if data == nil {
 		// can not take the buffer. Something must be wrong with the connection
 		errLog.Print("Busy buffer")
@@ -401,7 +401,7 @@ func (mc *mysqlConn) writeCommandPacketUint32(command byte, arg uint32) error {
 	// Reset Packet Sequence
 	mc.sequence = 0
 
-	data := mc.buf.smallWriteBuffer(4 + 1 + 4)
+	data := mc.buf.takeSmallBuffer(4 + 1 + 4)
 	if data == nil {
 		// can not take the buffer. Something must be wrong with the connection
 		errLog.Print("Busy buffer")
@@ -795,7 +795,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
 
 	if len(args) == 0 {
 		const pktLen = 1 + 4 + 1 + 4
-		data = mc.buf.writeBuffer(4 + pktLen)
+		data = mc.buf.takeBuffer(4 + pktLen)
 		if data == nil {
 			// can not take the buffer. Something must be wrong with the connection
 			errLog.Print("Busy buffer")