Skip to content

[4.2][stdlib] Speed up bridged Dictionary instances #17763

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

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented Jul 5, 2018

(Cherry-picked from #17742.)

Explanation: The bridged representations of native Swift Dictionary values currently implement a deprecated method in NSDictionary. Implementing the correct funnel leads to a ~5x speedup for certain operations on dictionaries bridged to Objective-C.
Scope: Affects dictionary bridging.
Issue: rdar://problem/39285882
Risk: Low. The change observable via the Objective-C runtime; however, this is unlikely to cause issues.
Testing: Standard test suite, including new tests and benchmarks.
Reviewer: @moiseev, @lancep

lorentey added 7 commits July 5, 2018 19:30
Dictionary’s native storage classes and _SwiftDeferredNSDictionary override -[NSDictionary getObjects:andKeys:] instead of its safer replacement, -[NSDictionary getObjects:andKeys:count:].

Overriding the correct method will considerably speed up some Cocoa operations on bridged dictionaries.

rdar://problem/39285882
(cherry picked from commit 6aec05a)
…ementations

This breaks out of the loop immediately when the last slot has been filled in the output buffer, skipping a final sequence of iterations over empty buckets.

(cherry picked from commit cf7e438)
@lorentey
Copy link
Member Author

lorentey commented Jul 5, 2018

@swift-ci please test

@lorentey
Copy link
Member Author

lorentey commented Jul 5, 2018

@swift-ci please nominate

@lorentey lorentey merged commit e0890e9 into swiftlang:swift-4.2-branch Jul 5, 2018
@lorentey lorentey deleted the nsdictionary-speedup-4.2 branch July 5, 2018 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant