Esempio n. 1
0
        private static ImmutableHashSet <T> MergeOrIntersect(ImmutableHashSet <T> value1, ImmutableHashSet <T> value2, bool merge)
        {
            if (value1.IsEmpty)
            {
                return(value2);
            }
            else if (value2.IsEmpty || ReferenceEquals(value1, value2))
            {
                return(value1);
            }

            // PERF: Avoid additional allocations by using the overload that takes a set argument
            // instead of IEnumerable argument.
            return(merge ? value1.AddRange(value2) : value1.IntersectSet(value2));
        }