@@ -1437,7 +1437,7 @@ extension Dictionary: Equatable where Value: Equatable {
1437
1437
}
1438
1438
1439
1439
for (k, v) in lhs {
1440
- let ( i, found) = rhsNative. _find ( k, startBucket : rhsNative . _bucket ( k ) )
1440
+ let ( i, found) = rhsNative. _find ( k)
1441
1441
if !found || rhsNative. value ( at: i. bucket) != v {
1442
1442
return false
1443
1443
}
@@ -2135,8 +2135,7 @@ final internal class _HashableTypedNativeDictionaryStorage<Key: Hashable, Value>
2135
2135
guard let nativeKey = _conditionallyBridgeFromObjectiveC ( aKey, Key . self)
2136
2136
else { return nil }
2137
2137
2138
- let ( i, found) = native. _find ( nativeKey,
2139
- startBucket: native. _bucket ( nativeKey) )
2138
+ let ( i, found) = native. _find ( nativeKey)
2140
2139
2141
2140
if found {
2142
2141
return native. bridgedValue ( at: i)
@@ -2553,6 +2552,12 @@ extension _NativeDictionary where Key: Hashable {
2553
2552
return ( bucket &- 1 ) & _bucketMask
2554
2553
}
2555
2554
2555
+ @inlinable // FIXME(sil-serialize-all)
2556
+ @inline ( __always)
2557
+ internal func _find( _ key: Key ) -> ( pos: Index , found: Bool ) {
2558
+ return _find ( key, startBucket: _bucket ( key) )
2559
+ }
2560
+
2556
2561
/// Search for a given key starting from the specified bucket.
2557
2562
///
2558
2563
/// If the key is not present, returns the position where it could be
@@ -2593,7 +2598,7 @@ extension _NativeDictionary where Key: Hashable {
2593
2598
/// This function does *not* update `count`.
2594
2599
@inlinable // FIXME(sil-serialize-all)
2595
2600
internal func unsafeAddNew( key newKey: Key , value: Value ) {
2596
- let ( i, found) = _find ( newKey, startBucket : _bucket ( newKey ) )
2601
+ let ( i, found) = _find ( newKey)
2597
2602
_precondition (
2598
2603
!found, " Duplicate key found in Dictionary. Keys may have been mutated after insertion " )
2599
2604
initializeKey ( newKey, value: value, at: i. bucket)
@@ -2610,8 +2615,7 @@ extension _NativeDictionary where Key: Hashable {
2610
2615
var dictionary = _NativeDictionary ( minimumCapacity: elements. count)
2611
2616
2612
2617
for (key, value) in elements {
2613
- let ( i, found) =
2614
- dictionary. _find ( key, startBucket: dictionary. _bucket ( key) )
2618
+ let ( i, found) = dictionary. _find ( key)
2615
2619
_precondition ( !found, " Dictionary literal contains duplicate keys " )
2616
2620
dictionary. initializeKey ( key, value: value, at: i. bucket)
2617
2621
}
@@ -2724,7 +2728,7 @@ extension _NativeDictionary/*: _DictionaryBuffer */ where Key: Hashable {
2724
2728
// Fast path that avoids computing the hash of the key.
2725
2729
return nil
2726
2730
}
2727
- let ( i, found) = _find ( key, startBucket : _bucket ( key ) )
2731
+ let ( i, found) = _find ( key)
2728
2732
return found ? i : nil
2729
2733
}
2730
2734
@@ -2736,7 +2740,7 @@ extension _NativeDictionary/*: _DictionaryBuffer */ where Key: Hashable {
2736
2740
return nil
2737
2741
}
2738
2742
2739
- let ( i, found) = _find ( key, startBucket : _bucket ( key ) )
2743
+ let ( i, found) = _find ( key)
2740
2744
if found {
2741
2745
return self . value ( at: i. bucket)
2742
2746
}
@@ -3552,7 +3556,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3552
3556
internal mutating func nativeUpdateValue(
3553
3557
_ value: Value , forKey key: Key
3554
3558
) -> Value ? {
3555
- var ( i, found) = asNative. _find ( key, startBucket : asNative . _bucket ( key ) )
3559
+ var ( i, found) = asNative. _find ( key)
3556
3560
3557
3561
let minBuckets = found
3558
3562
? asNative. bucketCount
@@ -3562,7 +3566,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3562
3566
3563
3567
let ( _, capacityChanged) = ensureUniqueNative ( withBucketCount: minBuckets)
3564
3568
if capacityChanged {
3565
- i = asNative. _find ( key, startBucket : asNative . _bucket ( key ) ) . pos
3569
+ i = asNative. _find ( key) . pos
3566
3570
}
3567
3571
3568
3572
let oldValue : Value ? = found ? asNative. value ( at: i. bucket) : nil
@@ -3638,7 +3642,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3638
3642
forKey key: Key , insertingDefault defaultValue: ( ) -> Value
3639
3643
) -> ( inserted: Bool , pointer: UnsafeMutablePointer < Value > ) {
3640
3644
3641
- var ( i, found) = asNative. _find ( key, startBucket : asNative . _bucket ( key ) )
3645
+ var ( i, found) = asNative. _find ( key)
3642
3646
if found {
3643
3647
let pointer = nativePointerToValue ( at: . _native( i) )
3644
3648
return ( inserted: false , pointer: pointer)
@@ -3648,7 +3652,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3648
3652
let ( _, capacityChanged) = ensureUniqueNative ( withCapacity: minCapacity)
3649
3653
3650
3654
if capacityChanged {
3651
- i = asNative. _find ( key, startBucket : asNative . _bucket ( key ) ) . pos
3655
+ i = asNative. _find ( key) . pos
3652
3656
}
3653
3657
3654
3658
asNative. initializeKey ( key, value: defaultValue ( ) , at: i. bucket)
@@ -3669,7 +3673,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3669
3673
_ value: Value , forKey key: Key
3670
3674
) -> ( inserted: Bool , memberAfterInsert: Value ) {
3671
3675
3672
- var ( i, found) = asNative. _find ( key, startBucket : asNative . _bucket ( key ) )
3676
+ var ( i, found) = asNative. _find ( key)
3673
3677
if found {
3674
3678
return ( inserted: false , memberAfterInsert: asNative. value ( at: i. bucket) )
3675
3679
}
@@ -3678,7 +3682,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3678
3682
let ( _, capacityChanged) = ensureUniqueNative ( withCapacity: minCapacity)
3679
3683
3680
3684
if capacityChanged {
3681
- i = asNative. _find ( key, startBucket : asNative . _bucket ( key ) ) . pos
3685
+ i = asNative. _find ( key) . pos
3682
3686
}
3683
3687
3684
3688
asNative. initializeKey ( key, value: value, at: i. bucket)
@@ -3720,7 +3724,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3720
3724
uniquingKeysWith combine: ( Value , Value ) throws -> Value
3721
3725
) rethrows where S. Element == ( Key , Value ) {
3722
3726
for (key, value) in keysAndValues {
3723
- var ( i, found) = asNative. _find ( key, startBucket : asNative . _bucket ( key ) )
3727
+ var ( i, found) = asNative. _find ( key)
3724
3728
3725
3729
if found {
3726
3730
// This is in a separate variable to make the uniqueness check work in
@@ -3737,7 +3741,7 @@ extension Dictionary._Variant: _DictionaryBuffer {
3737
3741
let minCapacity = asNative. count + 1
3738
3742
let ( _, capacityChanged) = ensureUniqueNative ( withCapacity: minCapacity)
3739
3743
if capacityChanged {
3740
- i = asNative. _find ( key, startBucket : asNative . _bucket ( key ) ) . pos
3744
+ i = asNative. _find ( key) . pos
3741
3745
}
3742
3746
3743
3747
asNative. initializeKey ( key, value: value, at: i. bucket)
@@ -3763,14 +3767,14 @@ extension Dictionary._Variant: _DictionaryBuffer {
3763
3767
defer { _fixLifetime ( asNative) }
3764
3768
for value in values {
3765
3769
let key = try keyForValue ( value)
3766
- var ( i, found) = asNative. _find ( key, startBucket : asNative . _bucket ( key ) )
3770
+ var ( i, found) = asNative. _find ( key)
3767
3771
if found {
3768
3772
asNative. values [ i. bucket] . append ( value)
3769
3773
} else {
3770
3774
let minCapacity = asNative. count + 1
3771
3775
let ( _, capacityChanged) = ensureUniqueNative ( withCapacity: minCapacity)
3772
3776
if capacityChanged {
3773
- i = asNative. _find ( key, startBucket : asNative . _bucket ( key ) ) . pos
3777
+ i = asNative. _find ( key) . pos
3774
3778
}
3775
3779
3776
3780
asNative. initializeKey ( key, value: [ value] , at: i. bucket)
0 commit comments