mirror of
https://github.com/miekg/dns.git
synced 2025-12-16 09:11:34 +01:00
Small tweak, next cleanup the tests
This commit is contained in:
parent
79547a0341
commit
3daa798e14
@ -1,10 +1,11 @@
|
|||||||
package dns
|
package dns
|
||||||
|
|
||||||
// Dedup removes identical RRs from rrs. It preserves the original ordering.
|
// Dedup removes identical RRs from rrs. It preserves the original ordering.
|
||||||
|
// The lowest TTL of any duplicates is used in the remaining one.
|
||||||
// TODO(miek): CNAME, DNAME 'n stuff.
|
// TODO(miek): CNAME, DNAME 'n stuff.
|
||||||
func Dedup(rrs []RR) []RR {
|
func Dedup(rrs []RR) []RR {
|
||||||
m := make(map[string]RR)
|
m := make(map[string]RR)
|
||||||
keys := []string{}
|
keys := make([]string, 0, len(rrs))
|
||||||
|
|
||||||
for _, r := range rrs {
|
for _, r := range rrs {
|
||||||
key := normalizedString(r)
|
key := normalizedString(r)
|
||||||
@ -19,8 +20,7 @@ func Dedup(rrs []RR) []RR {
|
|||||||
m[key] = r
|
m[key] = r
|
||||||
}
|
}
|
||||||
// If the length of the result map equals the amount of RRs we got,
|
// If the length of the result map equals the amount of RRs we got,
|
||||||
// it means they were all different. We can then just return the original
|
// it means they were all different. We can then just return the original rrset.
|
||||||
// rrset.
|
|
||||||
if len(m) == len(rrs) {
|
if len(m) == len(rrs) {
|
||||||
return rrs
|
return rrs
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user