Skip to content

Add a fast-path case for enumeration of keys and objects for bridged Dictionaries #6421

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 1 commit into from
Mar 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions stdlib/public/core/HashedCollections.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -3549,6 +3549,23 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
) {
bridgedAllKeysAndValues(objects, keys)
}

@objc(enumerateKeysAndObjectsWithOptions:usingBlock:)
internal func enumerateKeysAndObjects(options: Int,
using block: @convention(block) (Unmanaged<AnyObject>, Unmanaged<AnyObject>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can leave out the Unmanaged here; it's understood that blocks take arguments at +0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look at that tomorrow to verify the behavior is correct per Foundation changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping! I was just looking at this again over the weekend, and this would be a huge win

UnsafeMutablePointer<UInt8>) -> Void) {
bridgeEverything()
let capacity = nativeBuffer.capacity
var stop: UInt8 = 0
for position in 0..<capacity {
if bridgedBuffer.isInitializedEntry(at: position) {
block(Unmanaged.passUnretained(bridgedBuffer.key(at: position)),
Unmanaged.passUnretained(bridgedBuffer.value(at: position)),
&stop)
}
if stop != 0 { return }
}
}
%end

/// Returns the pointer to the stored property, which contains bridged
Expand Down