Skip to content

Add fast path for Overlaps when other is IReadOnlySet with fast lookup and same equality comparer #132763 - #134726

Open
Advitalitum wants to merge 6 commits into
dotnet:mainfrom
Advitalitum:main
Open

Advitalitum wants to merge 6 commits into
dotnet:mainfrom
Advitalitum:main

Conversation

@Advitalitum

@Advitalitum Advitalitum commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Similar to #132763

In FrozenSet.Overlaps(IEnumerable other) when other is IReadOnlySet with fast lookup and same comparer, we should iterate through the smaller set and search within the larger one.

// Benchmarks in progress

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 26, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

return false;
}

private static bool SmallerFrozenSetOverlapsLargerCompatibleReadOnlySetImpl(FrozenSet<T> smaller, IReadOnlySet<T> larger)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just have one method and switch arguments at call-site to keep it simpler?

@Advitalitum Advitalitum Sep 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be done for ISet as arguments, just need to duplicate method ComparersAreCompatible for ISet, but Immutable collections don't implement ISet

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Collections community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants