You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cty: Use WrangleMarksDeep for UnmarkDeep and UnmarkDeepWithPaths
These functions were previously using the "Transformer" mechanism, which is
very general but as a result ends up always conservatively rebuilding
the entire data structure it's given.
The recently-added WrangleMarksDeep relies on the fact that it can only
possibly change marks (not the actual values) to avoid building a new
value at all in the common case where there are no marks, to rebuild
only the parts of the structure that have mark changes when changes are
being made, and to reuse the internal "payload" values from the source
values while just wrapping them in a new outer cty.Value.
Testing with a benchmark in another codebase that makes heavy use of both
UnmarkDeep and UnmarkDeepWithPaths shows this being a material performance
improvement.
This also includes a bonus fast path for MarkWithPaths where it will skip
doing anything at all if the given slice of ParkValueMarks is empty.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@
12
12
13
13
-`cty.ValueMarksOfType` and `cty.ValueMarksOfTypeDeep` make it easier to use type-based rather than value-based mark schemes, where different values of a common type are used to track a specific kind of relationship with multiple external values.
14
14
-`cty.Value.HasMarkDeep` provides a "deep" version of the existing `cty.Value.HasMark`, searching throughout a possibly-nested structure for any values that have the given mark.
15
+
-`cty.Value.UnmarkDeep` and `cty.Value.UnmarkDeepWithPaths` are now implemented in terms of `cty.Value.WrangleMarksDeep`, so they benefit from its reduced overhead. In particular they avoid reconstructing a data structure that contains no marks at all.
16
+
-`cty.Value.MarkWithPaths` now has a fast path when it's given a zero-length `PathValueMarks`, in which case it just returns the value it was given with no modifications.
0 commit comments