Skip to content

Commit 9ae572f

Browse files
committed
[stdlib] Dictionary: Remove workaround for rdar://problem/44612356
1 parent ff882f4 commit 9ae572f

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

stdlib/public/core/Dictionary.swift

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,13 @@ extension Dictionary {
918918
return _variant.lookup(key) ?? defaultValue()
919919
}
920920
_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
923928
yield &address.pointee
924929
_fixLifetime(self)
925930
}
@@ -3544,19 +3549,6 @@ extension Dictionary._Variant {
35443549
}
35453550
}
35463551

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-
35603552
/// Ensure uniquely held native storage, while preserving the given index.
35613553
/// (If the variant had bridged storage, then the returned index will be the
35623554
/// corresponding native representation. Otherwise it's kept the same.)

0 commit comments

Comments
 (0)