Skip to content

Commit 1f070e7

Browse files
committed
---
yaml --- r: 229373 b: refs/heads/master-next c: 9ae572f h: refs/heads/master i: 229371: 3ed4984
1 parent b3a1e9a commit 1f070e7

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: a37c1f05e28110b00b679c219d162d85a7e2b546
3-
refs/heads/master-next: ff882f4a06439d277ecbca38f15d33eb38dfb321
3+
refs/heads/master-next: 9ae572f83f9edbb62464bbe1ab62fa176a3bfdea
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/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)