diff --git a/Sources/PersistentCollections/Node/_Node+Subtree Insertions.swift b/Sources/PersistentCollections/Node/_Node+Subtree Insertions.swift index bc4bbabb..876dc278 100644 --- a/Sources/PersistentCollections/Node/_Node+Subtree Insertions.swift +++ b/Sources/PersistentCollections/Node/_Node+Subtree Insertions.swift @@ -120,9 +120,9 @@ extension _Node { } @inlinable - internal mutating func update( + internal mutating func updateValue( _ level: _Level, - _ key: Key, + forKey key: Key, _ hash: _Hash, _ inserter: (UnsafeMutablePointer) -> Void ) -> (inserted: Bool, leaf: _UnmanagedNode, slot: _Slot) { @@ -159,7 +159,8 @@ extension _Node { case .descend(_, let slot): ensureUnique(isUnique: isUnique) let r = update { - $0[child: slot].update(level.descend(), key, hash, inserter) + $0[child: slot].updateValue( + level.descend(), forKey: key, hash, inserter) } if r.inserted { count &+= 1 } return r diff --git a/Sources/PersistentCollections/Node/_Node+Subtree Modify.swift b/Sources/PersistentCollections/Node/_Node+Subtree Modify.swift index a46207c6..70440470 100644 --- a/Sources/PersistentCollections/Node/_Node+Subtree Modify.swift +++ b/Sources/PersistentCollections/Node/_Node+Subtree Modify.swift @@ -127,7 +127,7 @@ extension _Node { _finalizeRemoval(.top, state.hash, at: state.path) case (false, true): // Insertion - let r = update(.top, state.key, state.hash) { + let r = updateValue(.top, forKey: state.key, state.hash) { $0.initialize(to: (state.key, state.value.unsafelyUnwrapped)) } assert(r.inserted) diff --git a/Sources/PersistentCollections/PersistentDictionary/PersistentDictionary.swift b/Sources/PersistentCollections/PersistentDictionary/PersistentDictionary.swift index 053a0a3f..bd2d3211 100644 --- a/Sources/PersistentCollections/PersistentDictionary/PersistentDictionary.swift +++ b/Sources/PersistentCollections/PersistentDictionary/PersistentDictionary.swift @@ -279,7 +279,9 @@ extension PersistentDictionary { _ value: __owned Value, forKey key: Key ) -> Value? { let hash = _Hash(key) - let r = _root.update(.top, key, hash) { $0.initialize(to: (key, value)) } + let r = _root.updateValue(.top, forKey: key, hash) { + $0.initialize(to: (key, value)) + } _invalidateIndices() if r.inserted { return nil } return _Node.UnsafeHandle.update(r.leaf) { @@ -296,7 +298,9 @@ extension PersistentDictionary { _ value: __owned Value, forKey key: Key ) -> Bool { let hash = _Hash(key) - let r = _root.update(.top, key, hash) { $0.initialize(to: (key, value)) } + let r = _root.updateValue(.top, forKey: key, hash) { + $0.initialize(to: (key, value)) + } if r.inserted { return true } _Node.UnsafeHandle.update(r.leaf) { $0[item: r.slot].value = value @@ -328,7 +332,7 @@ extension PersistentDictionary { with body: (inout Value) throws -> R ) rethrows -> R { let hash = _Hash(key) - let r = _root.update(.top, key, hash) { + let r = _root.updateValue(.top, forKey: key, hash) { $0.initialize(to: (key, defaultValue())) } return try _Node.UnsafeHandle.update(r.leaf) { diff --git a/Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra basics.swift b/Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra basics.swift index 1986ecb1..f872c3bc 100644 --- a/Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra basics.swift +++ b/Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra basics.swift @@ -24,7 +24,7 @@ extension PersistentSet: SetAlgebra { ) -> (inserted: Bool, memberAfterInsert: Element) { let hash = _Hash(newMember) _invalidateIndices() - let r = _root.update(.top, newMember, hash) { + let r = _root.insert(.top, newMember, hash) { $0.initialize(to: (newMember, ())) } if r.inserted { @@ -39,13 +39,12 @@ extension PersistentSet: SetAlgebra { @inlinable internal mutating func _insert(_ newMember: __owned Element) -> Bool { let hash = _Hash(newMember) - let r = _root.update(.top, newMember, hash) { + let r = _root.insert(.top, newMember, hash) { $0.initialize(to: (newMember, ())) } return r.inserted } - @discardableResult @inlinable public mutating func remove(_ member: Element) -> Element? { @@ -58,7 +57,7 @@ extension PersistentSet: SetAlgebra { @inlinable public mutating func update(with newMember: __owned Element) -> Element? { let hash = _Hash(newMember) - let r = _root.update(.top, newMember, hash) { + let r = _root.updateValue(.top, forKey: newMember, hash) { $0.initialize(to: (newMember, ())) } if r.inserted { return nil }