-
Notifications
You must be signed in to change notification settings - Fork 10.5k
stdlib: two small Array improvements #28486
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
Conversation
Use _CocoaArrayWrapper.endIndex which returns the NSArray.count. In the old version, "count" translated to RandomAccessCollection.count, which ended up in multiple calls to endIndex.
@swift-ci test |
@swift-ci benchmark |
Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -Onone
Code size: -swiftlibs
How to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
Build failed |
Build failed |
This makes Array.first much small and more efficient. Without this, Array.first compiled down to RandomAccessCollection.first, which ended up in pretty unefficient code. rdar://problem/46291397
ed69ab5
to
3e932c0
Compare
@swift-ci test |
1 similar comment
@swift-ci test |
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.
thanks!
Similar to swiftlang#28486 in motivation. Before this change 'count' got lowered to multiple 'endIndex' calls Fixes rdar://46702232
Use _CocoaArrayWrapper.endIndex which returns the NSArray.count.
In the old version, "count" translated to RandomAccessCollection.count, which ended up in multiple calls to endIndex.
Without this, Array.first compiled down to RandomAccessCollection.first, which ended up in pretty unefficient code.
rdar://problem/46291397