From 64c983275e174b8fc620b0cdad3475599bbdd057 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 27 Jun 2025 09:42:13 -0400 Subject: [PATCH] skip set elem comparison when already matched If both elements of the set have already been matched, there is no need to compare them again. --- internal/plans/objchange/compatible.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/plans/objchange/compatible.go b/internal/plans/objchange/compatible.go index 18970ec2b1..0267c52d55 100644 --- a/internal/plans/objchange/compatible.go +++ b/internal/plans/objchange/compatible.go @@ -366,6 +366,14 @@ func assertSetValuesCompatible(planned, actual cty.Value, path cty.Path, f func( beqs := make([]bool, len(bs)) for ai, av := range as { for bi, bv := range bs { + if aeqs[ai] && beqs[bi] { + // because the best we can do is check that a value correlates + // with some other value in the other set, one or both values + // might have already been matched. If they have both matched in + // some way there's no need run the check again. + continue + } + if f(av, bv) { aeqs[ai] = true beqs[bi] = true