Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider switching to reference-based value comparer when a primitive collection is immutable/read-only #31374

Open
roji opened this issue Jul 29, 2023 · 1 comment

Comments

@roji
Copy link
Member

roji commented Jul 29, 2023

Our default value comparer(s) for primitive collections do deep comparison, i.e. they check equality for each and every element. When we implement nested primitive collections (#30713), this will have to be recursive.

If the primitive collection type is known to be immutable (e.g. implements IImmutableList), we can instead switch to the much cheaper reference comparison instead.

One possible objection here is that the immutable list may contain mutable elements, in which case the value comparer would miss something being changed (IIRC we discussed this and decided its OK).

@ajcvickers
Copy link
Contributor

Note we can do this safely if we can determine that the elements really are immutable, which could be related to general work to support immutable types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants