Skip to content

Commit a72544f

Browse files
committed
[stdlib] Speed up ObjectIdentifier-keyed dictionaries
ObjectIdentifier is used relatively frequently as the Key type for dictionaries, so it makes sense for it to implement single-shot hashing. This will lead to a measurable speedup in lookup/insertion performance. rdar://88339458
1 parent 9e93369 commit a72544f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/core/ObjectIdentifier.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ extension ObjectIdentifier: Hashable {
9595
public func hash(into hasher: inout Hasher) {
9696
hasher.combine(Int(Builtin.ptrtoint_Word(_value)))
9797
}
98+
99+
@_alwaysEmitIntoClient // For back deployment
100+
public func _rawHashValue(seed: Int) -> Int {
101+
Int(Builtin.ptrtoint_Word(_value))._rawHashValue(seed: seed)
102+
}
98103
}
99104

100105
extension UInt {

0 commit comments

Comments
 (0)