Avoid allocation for WriteBuf on query
This commit is contained in:
@@ -47,6 +47,7 @@ type Conn struct {
|
||||
lastActivityTime time.Time // the last time the connection was used
|
||||
reader *bufio.Reader // buffered reader to improve read performance
|
||||
wbuf [1024]byte
|
||||
writeBuf WriteBuf
|
||||
Pid int32 // backend pid
|
||||
SecretKey int32 // key to use to send a cancel query message to the server
|
||||
RuntimeParams map[string]string // parameters that have been reported by the server
|
||||
|
||||
+2
-1
@@ -91,7 +91,8 @@ func (self PgError) Error() string {
|
||||
|
||||
func newWriteBuf(c *Conn, t byte) *WriteBuf {
|
||||
buf := append(c.wbuf[0:0], t, 0, 0, 0, 0)
|
||||
return &WriteBuf{buf: buf, sizeIdx: 1, conn: c}
|
||||
c.writeBuf = WriteBuf{buf: buf, sizeIdx: 1, conn: c}
|
||||
return &c.writeBuf
|
||||
}
|
||||
|
||||
// WrifeBuf is used build messages to send to the PostgreSQL server. It is used
|
||||
|
||||
Reference in New Issue
Block a user