mirror of
https://github.com/apple/swift-collections
synced 2026-11-24 04:27:53 +00:00
Continue applying refactors and optimizations.
Key Changes: - _BTree.init() dynamically computes capacity from stride - _BTree.UnsafePath uses Unmanaged +0 references. Minor Changes: - Fix _BTree.Iterator bug on single-leaf trees.
This commit is contained in:
25 files changed
+195
-179
No files matched your search
@@ -20,7 +20,7 @@ extension SortedSet {
|
||||
self.init()
|
||||
|
||||
for element in elements {
|
||||
self._root.setAnyValue((), forKey: element)
|
||||
self._root.updateAnyValue((), forKey: element)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ extension SortedSet {
|
||||
public mutating func insert(
|
||||
_ newMember: Element
|
||||
) -> (inserted: Bool, memberAfterInsert: Element) {
|
||||
if let oldKey = self._root.setAnyValue((), forKey: newMember, updatingKey: false)?.key {
|
||||
if let oldKey = self._root.updateAnyValue((), forKey: newMember, updatingKey: false)?.key {
|
||||
return (inserted: false, memberAfterInsert: oldKey)
|
||||
} else {
|
||||
return (inserted: true, memberAfterInsert: newMember)
|
||||
@@ -80,6 +80,6 @@ extension SortedSet {
|
||||
@inline(__always)
|
||||
@discardableResult
|
||||
public mutating func update(with newMember: Element) -> Element? {
|
||||
return self._root.setAnyValue((), forKey: newMember, updatingKey: true)?.key
|
||||
return self._root.updateAnyValue((), forKey: newMember, updatingKey: true)?.key
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user