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

Make use of fast HashSet.Contains check #884

Merged
merged 1 commit into from Aug 17, 2021
Merged

Conversation

weltkante
Copy link
Contributor

Fixes #883

Moving the typecast up into the if-condition so it can be leveraged for the Contains-check. When the interface is not a JoinableTask it can't be in the HashSet<JoinableTask> so you can just skip the branch in this case.

Not doing this means there is a type-mismatch between the HashSet<JoinableTask> and the variable you're checking (IJoinableTaskDependent) which causes C# to pick the LINQ Enumerable.Contains extension over the HashSet.Contains member.

@AArnott AArnott added this to the v17.0 milestone Aug 17, 2021
@AArnott AArnott merged commit fe255fd into microsoft:main Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perf: Slow LINQ Contains method being used
3 participants