configgraph: ContributingResourceInstances uses ValueMarksOfTypeDeep

Recent changes in cty have included some new functions for working with
marks more efficiently. This particular function allows us to iterate over
the deep marks on a value without creating a new unmarked copy of the
value and without building an intermediate map of marks.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
Martin Atkins
2025-09-05 13:39:12 -07:00
parent 352e23e8f3
commit 3a31ce9c28

View File

@@ -58,13 +58,10 @@ func ContributingResourceInstances(v cty.Value) iter.Seq[*ResourceInstance] {
// multiple references to the same resource instance as long as the
// pointers are unique, but the doc comment above reserves the right
// to change our approach here in future, if needed.)
_, marks := v.UnmarkDeep()
return func(yield func(*ResourceInstance) bool) {
for mark := range marks {
if mark, ok := mark.(ResourceInstanceMark); ok {
if !yield(mark.instance) {
break
}
for mark := range cty.ValueMarksOfTypeDeep[ResourceInstanceMark](v) {
if !yield(mark.instance) {
break
}
}
}