Skip to content

Commit 56653c4

Browse files
committed
Introduce removeCellAtIndex function that takes nullable MutabilityOwnership
It replaces removeCellAtIndex and mutableRemoveCellAtIndex
1 parent 0483f2c commit 56653c4

File tree

1 file changed

+3
-12
lines changed
  • core/commonMain/src/implementations/immutableSet

1 file changed

+3
-12
lines changed

core/commonMain/src/implementations/immutableSet/TrieNode.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,10 @@ internal class TrieNode<E>(
180180
}
181181

182182

183-
private fun removeCellAtIndex(cellIndex: Int, positionMask: Int): TrieNode<E> {
183+
private fun removeCellAtIndex(cellIndex: Int, positionMask: Int, owner: MutabilityOwnership?): TrieNode<E> {
184184
// assert(!hasNoCellAt(positionMask))
185185
// assert(buffer.size > 1) can be false only for the root node
186186

187-
val newBitmap = bitmap xor positionMask
188-
val newBuffer = buffer.removeCellAtIndex(cellIndex)
189-
return setProperties(newBitmap, newBuffer, owner = null)
190-
}
191-
192-
private fun mutableRemoveCellAtIndex(cellIndex: Int, positionMask: Int, owner: MutabilityOwnership): TrieNode<E> {
193-
// assert(!hasNoCellAt(positionMask))
194-
// assert(buffer.size > 1)
195-
196187
val newBitmap = bitmap xor positionMask
197188
val newBuffer = buffer.removeCellAtIndex(cellIndex)
198189
return setProperties(newBitmap, newBuffer, owner)
@@ -763,7 +754,7 @@ internal class TrieNode<E>(
763754
}
764755
// element is directly in buffer
765756
if (element == buffer[cellIndex]) {
766-
return removeCellAtIndex(cellIndex, cellPositionMask)
757+
return removeCellAtIndex(cellIndex, cellPositionMask, owner = null)
767758
}
768759
return this
769760
}
@@ -793,7 +784,7 @@ internal class TrieNode<E>(
793784
// element is directly in buffer
794785
if (element == buffer[cellIndex]) {
795786
mutator.size--
796-
return mutableRemoveCellAtIndex(cellIndex, cellPositionMask, mutator.ownership) // check is empty
787+
return removeCellAtIndex(cellIndex, cellPositionMask, mutator.ownership) // check is empty
797788
}
798789
return this
799790
}

0 commit comments

Comments
 (0)