diff --git a/internal/addrs/module.go b/internal/addrs/module.go index 4d71034d1986..2ae264144805 100644 --- a/internal/addrs/module.go +++ b/internal/addrs/module.go @@ -4,6 +4,7 @@ package addrs import ( + "slices" "strings" "github.com/hashicorp/hcl/v2" @@ -58,15 +59,7 @@ func (m Module) String() string { } func (m Module) Equal(other Module) bool { - if len(m) != len(other) { - return false - } - for i := range m { - if m[i] != other[i] { - return false - } - } - return true + return slices.Equal(m, other) } type moduleKey string diff --git a/internal/addrs/module_instance.go b/internal/addrs/module_instance.go index 5ebce0ab95d9..9e8e85e64b26 100644 --- a/internal/addrs/module_instance.go +++ b/internal/addrs/module_instance.go @@ -5,6 +5,7 @@ package addrs import ( "fmt" + "slices" "strings" "github.com/hashicorp/hcl/v2" @@ -305,16 +306,7 @@ func (mk moduleInstanceKey) uniqueKeySigil() {} // Equal returns true if the receiver and the given other value // contains the exact same parts. func (m ModuleInstance) Equal(o ModuleInstance) bool { - if len(m) != len(o) { - return false - } - - for i := range m { - if m[i] != o[i] { - return false - } - } - return true + return slices.Equal(m, o) } // Less returns true if the receiver should sort before the given other value