-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Resolving some FIXME comments on Set type. #20631
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de2bd7b
Fixing some fixmes on stdlib Set
LucianoPAlmeida 96a6b40
Adding @inline attr
LucianoPAlmeida 05bd993
Fixing spaces
LucianoPAlmeida 15d80de
Adding isEmpty as fast path in other places where is possible.
LucianoPAlmeida dadd251
Quotes on variable name on comment.
LucianoPAlmeida 9cda47f
Update stdlib/public/core/Set.swift
natecook1000 6618421
Merge remote-tracking branch 'origin/master' into set-fixmes
LucianoPAlmeida 52d8370
Adding benchmark for isDisjoint Set method
LucianoPAlmeida 478c4d1
Adding empty sets to benchmark
LucianoPAlmeida 7f46d25
Fixing the factor on benchmarks and naming warnings for empty 5 words
LucianoPAlmeida File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in the comment, there are places "elsewhere" that could use an
isEmpty
fast path. Before deleting the fixme, it'd be important to identify where those other places are and either implement the fast path or add the fixme comment there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure @xwu 👍
I've checked the methods on Set and added it in all places that I could find it would be possible :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not so sure you got everything. Wouldn’t
isSuperset
benefit from anisEmpty
fast path?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've check this
isSuperset
, but didn't think it has benefit, is an interesting case because just because we have two cases thereSo to add an
isEmpty
fast path will require, check also possibleSubset for empty too, but since it is a arbitrary sequence it doens't have anisEmpty
and as far as I know we could not do this check on underestimatedCount.Also looking to the implementation(below) no matter what is the size of
possibleSubset
if self is empty it will return on the first iteration because contains will return false. So there's no performance problem because it will not iterate unnecessarily. Basically, that is the reason I think is not a benefit :))There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out there was more "elsewhere":
isStrictSubset
andisStrictSuperset
withSequence
parameter could probably also benefit form optimizations forisEmpty
cases... see #24156 (comment).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@palimondo Sorry I miss those 😅, I'll take a look and I can patch up a PR later today :))
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Please don't go in there now, #21300 is about to drastically change how that's handled and
I'm already looking into how to handleit only pays the cheap creation ofisEmpty
cases on top of it…_Bitset(capacity: self.bucketCount)
and will bail out of theSequence
consuming loop ASAP.I just couldn't resist noting how @xwu's pedantry usually turns out to be right, even though it feels pretty annoying to be on the receiving end of it (speaking from experience 😉).