Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Remove unused paths in Set.#5778

Merged
VSadov merged 2 commits intodotnet:masterfrom
JonHanna:optimise_set
Jan 29, 2016
Merged

Remove unused paths in Set.#5778
VSadov merged 2 commits intodotnet:masterfrom
JonHanna:optimise_set

Conversation

@JonHanna
Copy link
Copy Markdown
Contributor

Set in Linq and Linq.Parallel never has Add() called after Remove(). Remove paths and fields only necessary in that case.

Add debug-only check on this assumption, so any new uses that break this assumption are flagged to the developer.

IntersectQueryOperator does a call to Contains() followed by a call to Remove() on the same set for the same value. Since Remove() takes a very similar path to Contains() in checking for existance, and returns false when the item to remove isn't found, this can be simplified to just Remove().

Also remove unused constructor on Set.

This will allow for further improvements to Enumerable.Distinct() and Enumerable.Union() in conjunction with #5777.

IntersectQueryOperator does a call to Contains followed by a call to
Remove on the same set for the same value. Since Remove takes a very
similar path to Contains in checking for existance, and returns false
when the item to remove isn't found, this can be simplified to just Remove.

Also remove unused constructor on Set.
Set in Linq and Linq.Parallel never has Add called after Remove. Remove
paths and fields only necessary in that case.

Add debug-only check on this assumption, so any new uses that break
this assumption are flagged to the developer.
@stephentoub
Copy link
Copy Markdown
Member

cc: @VSadov, @AlfredoMS

LGTM

@VSadov
Copy link
Copy Markdown
Member

VSadov commented Jan 29, 2016

LGTM

VSadov added a commit that referenced this pull request Jan 29, 2016
@VSadov VSadov merged commit 51489e2 into dotnet:master Jan 29, 2016
@JonHanna JonHanna deleted the optimise_set branch January 29, 2016 23:05
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants