aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-04-12 22:23:23 +0700
committerShulhan <ms@kilabit.info>2019-04-12 22:23:23 +0700
commitdd7a23af81939453c3bb46a44676e8523b69ee5c (patch)
tree3b614a6063876fda1b84bb2cb67b05a218aa75ab
parente460113b3219dc3a56d03cfb9d0f091890cd9c16 (diff)
downloadpakakeh.go-dd7a23af81939453c3bb46a44676e8523b69ee5c.tar.xz
dns: remove unnecessary index when updating answer
-rw-r--r--lib/dns/answers.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/dns/answers.go b/lib/dns/answers.go
index 01813ec4..c9e339eb 100644
--- a/lib/dns/answers.go
+++ b/lib/dns/answers.go
@@ -58,17 +58,16 @@ func (ans *answers) remove(qtype, qclass uint16) {
//
// upsert update or insert new answer to list.
-// If answer is updated, it will return the old answer; otherwise new insert
-// is inserted to list and it will return nil instead.
+// If new answer is updated, it will return the old answer.
+// If new answer is inserted, it will return nil instead.
//
func (ans *answers) upsert(nu *answer) (an *answer) {
if nu == nil || nu.msg == nil {
return
}
- var x int
- an, x = ans.get(nu.qtype, nu.qclass)
+ an, _ = ans.get(nu.qtype, nu.qclass)
if an != nil {
- ans.v[x].update(nu)
+ an.update(nu)
} else {
ans.v = append(ans.v, nu)
}