2
0

RowDescription.Name is now []byte

Avoid allocation
This commit is contained in:
Jack Christensen
2019-04-18 23:12:00 -05:00
parent 2acb7b6d4e
commit 8d43b38287
+2 -3
View File
@@ -14,7 +14,7 @@ const (
) )
type FieldDescription struct { type FieldDescription struct {
Name string Name []byte
TableOID uint32 TableOID uint32
TableAttributeNumber uint16 TableAttributeNumber uint16
DataTypeOID uint32 DataTypeOID uint32
@@ -46,9 +46,8 @@ func (dst *RowDescription) Decode(src []byte) error {
if idx < 0 { if idx < 0 {
return &invalidMessageFormatErr{messageType: "RowDescription"} return &invalidMessageFormatErr{messageType: "RowDescription"}
} }
bName := string(src[rp : rp+idx]) fd.Name = src[rp : rp+idx]
rp += idx + 1 rp += idx + 1
fd.Name = string(bName[:len(bName)-1])
// Since buf.Next() doesn't return an error if we hit the end of the buffer // Since buf.Next() doesn't return an error if we hit the end of the buffer
// check Len ahead of time // check Len ahead of time