2
0

Avoid allocation for WriteBuf on query

This commit is contained in:
Jack Christensen
2016-04-30 13:32:19 -05:00
parent 9288322a4f
commit b596fa3455
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -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
View File
@@ -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