Simplify ForAttributeWithMetadataName #72979
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Discussions with @sharwell have indicated that thsi code is not necessary. Specifically, consider the semantics of what 'Collect' does. It takes in the N values from an
IncrementalValuesProvider
(noteValues
notValue
), and produces anIncrementalValueProvider
containing anImmutableArray<>
comprised of those individual values.Now, consider an
IncrementalValuesProvider<T>
P1
which produces anIncrementalValueProvider<ImmutableArray<T>>
P2
by doingP1.Collect()
. IfP1
produces the same values as its prior run, then that will be detected by the engine, which will cut off further processing, keepingP2
with the same array as hte prior run.If, however,
P1
does change in any way (according to its comparer) then we necessarily must get a new array inP2
containing those values. There is no need or value here forP2
to have any sort of array-comparer as we actually want array-identity to determine if P2 is creating new outputs or not.--
Consider an example. Say that
P1
produced"1", "2", "3"
, and thusP2
is["1", "2", "3"]
. If on rerun, P1 produces the same values (by equality, not necessarily identity), then we will get the same array, which will already behave properly with reference equality semantics. If we change to"1", "2", "4"
though, and we produce["1", "2", "4"]
, it does no good to do sequence equality for these arrays. They will be different (as otherwise we wouldn't generate the ImmutableArray in the first place). As such, doing a reference-equality check is actually preferred as it's O(1) instead of O(n).