ImmutableHashSet<T>.SetEquals always creates a new HashSet<T> #90986
Open
Description
opened on Aug 23, 2023
The following HashSet<T>
calculation could be avoided by using other.WithComparer(origin.KeyComparer)
in the specific case where other
is already an ImmutableHashSet<T>
. It might also be avoidable in the case where other
is already a HashSet<T>
with an appropriate comparer.
Note that in addition to the overhead of performing these checks at runtime, there may be overhead added by the fact that ImmutableHashSet<T>
has a slower enumerator than HashSet<T>
, and the newly allocated set is immediately enumerated.
Activity