-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Improve Dictionary.Keys.contains(_:) #16310
Conversation
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.
Very nice!
@swift-ci please test |
@swift-ci please benchmark |
@@ -0,0 +1,70 @@ | |||
//===--- DictionaryKeysContains.swift -------------------------------------------===// |
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.
Nit: Please fix the header so that it's 80-characters wide; below, please consistently use two-space indents and wrap to 80-characters.
Anyway, this is awesome!
Build comment file:Optimized (O)Regression (10)
Improvement (7)
No Changes (410)
Added (2)
Unoptimized (Onone)Regression (12)
Improvement (9)
No Changes (406)
Added (2)
Hardware Overview
|
@swift-ci smoke test |
@swift-ci smoke benchmark |
@swift-ci smoke test |
Build comment file:Optimized (O)Regression (17)
Improvement (25)
No Changes (385)
Added (2)
Unoptimized (Onone)Regression (14)
Improvement (9)
No Changes (404)
Added (2)
Hardware Overview
|
@lorentey Thank you. I don't care if it is squashed. |
LGTM! |
Dictionary.Keys.contains(_:)
takes O(1) for native dictionaries. However it takes O(n) when dictionaries wrap aNSDictionary
. This PR makes it to take just O(1) even when wrapping aNSDictionary
.Benchmark results
Before
After