refactor: use slices.Equal to simplify code (#7426)

This commit is contained in:
houpo-bob
2025-07-29 03:04:53 +08:00
committed by GitHub
parent 1a30dd9695
commit 2c2b075eaa

View File

@@ -13,6 +13,8 @@
package fall package fall
import ( import (
"slices"
"github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin"
) )
@@ -48,15 +50,7 @@ func (f *F) SetZonesFromArgs(zones []string) {
// Equal returns true if f and g are equal. // Equal returns true if f and g are equal.
func (f *F) Equal(g F) bool { func (f *F) Equal(g F) bool {
if len(f.Zones) != len(g.Zones) { return slices.Equal(f.Zones, g.Zones)
return false
}
for i := range f.Zones {
if f.Zones[i] != g.Zones[i] {
return false
}
}
return true
} }
// Zero returns a zero valued F. // Zero returns a zero valued F.