Skip to content

Commit 3e033bd

Browse files
committed
Remove unnecessary allocation.
1 parent 8ad2b29 commit 3e033bd

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

conn.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (c *conn) handlePgpass(o values) {
164164
return
165165
}
166166
mode := fileinfo.Mode()
167-
if mode & (0x77) != 0 {
167+
if mode&(0x77) != 0 {
168168
// XXX should warn about incorrect .pgpass permissions as psql does
169169
return
170170
}
@@ -180,7 +180,7 @@ func (c *conn) handlePgpass(o values) {
180180
db := o.Get("dbname")
181181
username := o.Get("user")
182182
// From: https://github.com/tg/pgpass/blob/master/reader.go
183-
getFields := func (s string) []string {
183+
getFields := func(s string) []string {
184184
fs := make([]string, 0, 5)
185185
f := make([]rune, 0, len(s))
186186

@@ -200,7 +200,7 @@ func (c *conn) handlePgpass(o values) {
200200
}
201201
}
202202
return append(fs, string(f))
203-
}
203+
}
204204
for scanner.Scan() {
205205
line := scanner.Text()
206206
if len(line) == 0 || line[0] == '#' {
@@ -210,7 +210,7 @@ func (c *conn) handlePgpass(o values) {
210210
if len(split) != 5 {
211211
continue
212212
}
213-
if (split[0] == "*" || split[0] == hostname || (split[0] == "localhost" && (hostname == "" || ntw == "unix"))) && (split[1] == "*" || split[1] == port) && (split[2] == "*" || split[2] == db) && (split[3] == "*" || split[3] == username) {
213+
if (split[0] == "*" || split[0] == hostname || (split[0] == "localhost" && (hostname == "" || ntw == "unix"))) && (split[1] == "*" || split[1] == port) && (split[2] == "*" || split[2] == db) && (split[3] == "*" || split[3] == username) {
214214
o["password"] = split[4]
215215
return
216216
}
@@ -614,8 +614,6 @@ func (cn *conn) simpleExec(q string) (res driver.Result, commandTag string, err
614614
func (cn *conn) simpleQuery(q string) (res *rows, err error) {
615615
defer cn.errRecover(&err)
616616

617-
st := &stmt{cn: cn, name: ""}
618-
619617
b := cn.writeBuf('Q')
620618
b.string(q)
621619
cn.send(b)
@@ -634,10 +632,7 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
634632
}
635633
if res == nil {
636634
res = &rows{
637-
cn: cn,
638-
colNames: st.colNames,
639-
colTyps: st.colTyps,
640-
colFmts: st.colFmts,
635+
cn: cn,
641636
}
642637
}
643638
res.done = true

0 commit comments

Comments
 (0)