File tree 2 files changed +31
-10
lines changed
2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,35 @@ extension __RawDictionaryStorage {
196
196
return Builtin . bridgeFromRawPointer (
197
197
Builtin . addressof ( & _swiftEmptyDictionarySingleton) )
198
198
}
199
+
200
+ @_alwaysEmitIntoClient
201
+ @inline ( __always)
202
+ internal final func uncheckedKey< Key: Hashable > ( at bucket: _HashTable . Bucket ) -> Key {
203
+ defer { _fixLifetime ( self ) }
204
+ _internalInvariant ( _hashTable. isOccupied ( bucket) )
205
+ let keys = _rawKeys. assumingMemoryBound ( to: Key . self)
206
+ return keys [ bucket. offset]
207
+ }
208
+
209
+ @_alwaysEmitIntoClient
210
+ @inline ( never)
211
+ internal final func find< Key: Hashable > ( _ key: Key ) -> ( bucket: _HashTable . Bucket , found: Bool ) {
212
+ return find ( key, hashValue: key. _rawHashValue ( seed: _seed) )
213
+ }
214
+
215
+ @_alwaysEmitIntoClient
216
+ @inline ( never)
217
+ internal final func find< Key: Hashable > ( _ key: Key , hashValue: Int ) -> ( bucket: _HashTable . Bucket , found: Bool ) {
218
+ let hashTable = _hashTable
219
+ var bucket = hashTable. idealBucket ( forHashValue: hashValue)
220
+ while hashTable. _isOccupied ( bucket) {
221
+ if uncheckedKey ( at: bucket) == key {
222
+ return ( bucket, true )
223
+ }
224
+ bucket = hashTable. bucket ( wrappedAfter: bucket)
225
+ }
226
+ return ( bucket, false )
227
+ }
199
228
}
200
229
201
230
@usableFromInline
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ extension _NativeDictionary { // Low-level lookup operations
161
161
@inlinable
162
162
@inline ( __always)
163
163
internal func find( _ key: Key ) -> ( bucket: Bucket , found: Bool ) {
164
- return find ( key, hashValue : self . hashValue ( for : key ) )
164
+ return _storage . find ( key)
165
165
}
166
166
167
167
/// Search for a given element, assuming it has the specified hash value.
@@ -174,15 +174,7 @@ extension _NativeDictionary { // Low-level lookup operations
174
174
_ key: Key ,
175
175
hashValue: Int
176
176
) -> ( bucket: Bucket , found: Bool ) {
177
- let hashTable = self . hashTable
178
- var bucket = hashTable. idealBucket ( forHashValue: hashValue)
179
- while hashTable. _isOccupied ( bucket) {
180
- if uncheckedKey ( at: bucket) == key {
181
- return ( bucket, true )
182
- }
183
- bucket = hashTable. bucket ( wrappedAfter: bucket)
184
- }
185
- return ( bucket, false )
177
+ return _storage. find ( key, hashValue: hashValue)
186
178
}
187
179
}
188
180
You can’t perform that action at this time.
0 commit comments