@@ -918,8 +918,13 @@ extension Dictionary {
918
918
return _variant. lookup ( key) ?? defaultValue ( )
919
919
}
920
920
_modify {
921
- let index = _variant. lookupOrInsert ( key, default: defaultValue)
922
- let address = _variant. asNative. _values + index. bucket
921
+ let ( index, found) = _variant. mutatingFind ( key)
922
+ let native = _variant. asNative
923
+ if !found {
924
+ let value = defaultValue ( )
925
+ native. _insert ( at: index, key: key, value: value)
926
+ }
927
+ let address = native. _values + index. bucket
923
928
yield & address. pointee
924
929
_fixLifetime ( self )
925
930
}
@@ -3544,19 +3549,6 @@ extension Dictionary._Variant {
3544
3549
}
3545
3550
}
3546
3551
3547
- @usableFromInline // FIMXE: Should be @inlinable (rdar://problem/44612356)
3548
- internal mutating func lookupOrInsert(
3549
- _ key: Key ,
3550
- default defaultValue: ( ) -> Value
3551
- ) -> _NativeDictionary < Key , Value > . Index {
3552
- let ( index, found) = mutatingFind ( key)
3553
- if !found {
3554
- let value = defaultValue ( )
3555
- asNative. _insert ( at: index, key: key, value: value)
3556
- }
3557
- return index
3558
- }
3559
-
3560
3552
/// Ensure uniquely held native storage, while preserving the given index.
3561
3553
/// (If the variant had bridged storage, then the returned index will be the
3562
3554
/// corresponding native representation. Otherwise it's kept the same.)
0 commit comments