Skip to content

Commit bb674fe

Browse files
authored
Merge pull request swiftlang#6421 from phausler/dictionary_bridge_perf
Add a fast-path case for enumeration of keys and objects for bridged Dictionaries
2 parents 17e8ce4 + 7d01c5d commit bb674fe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

stdlib/public/core/HashedCollections.swift.gyb

+17
Original file line numberDiff line numberDiff line change
@@ -3563,6 +3563,23 @@ final internal class _SwiftDeferredNS${Self}<${TypeParametersDecl}>
35633563
) {
35643564
bridgedAllKeysAndValues(objects, keys)
35653565
}
3566+
3567+
@objc(enumerateKeysAndObjectsWithOptions:usingBlock:)
3568+
internal func enumerateKeysAndObjects(options: Int,
3569+
using block: @convention(block) (Unmanaged<AnyObject>, Unmanaged<AnyObject>,
3570+
UnsafeMutablePointer<UInt8>) -> Void) {
3571+
bridgeEverything()
3572+
let capacity = nativeBuffer.capacity
3573+
var stop: UInt8 = 0
3574+
for position in 0..<capacity {
3575+
if bridgedBuffer.isInitializedEntry(at: position) {
3576+
block(Unmanaged.passUnretained(bridgedBuffer.key(at: position)),
3577+
Unmanaged.passUnretained(bridgedBuffer.value(at: position)),
3578+
&stop)
3579+
}
3580+
if stop != 0 { return }
3581+
}
3582+
}
35663583
%end
35673584

35683585
/// Returns the pointer to the stored property, which contains bridged

0 commit comments

Comments
 (0)