Skip to content

Commit ee4c5f6

Browse files
author
Abduqodiri Qurbonzoda
committed
Allow hashMap collisions to be located at any level
1 parent c29c2a9 commit ee4c5f6

File tree

3 files changed

+157
-78
lines changed

3 files changed

+157
-78
lines changed

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableMap/PersistentHashMapBuilderContentIterators.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal abstract class PersistentHashMapBuilderBaseIterator<K, V, T>(private va
8888

8989
val nodeIndex = node.nodeIndex(keyPositionMask)
9090
val targetNode = node.nodeAtIndex(nodeIndex)
91-
if (shift == MAX_SHIFT) { // collision
91+
if (targetNode.isCollision()) {
9292
path[pathIndex].reset(node.buffer, node.buffer.size, 0)
9393
while (path[pathIndex].currentKey() != key) {
9494
path[pathIndex].moveToNextKey()

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableMap/PersistentHashMapContentIterators.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ internal abstract class PersistentHashMapBaseIterator<K, V, T>(node: TrieNode<K,
107107
}
108108
if (path[pathIndex].hasNextNode()) {
109109
val node = path[pathIndex].currentNode()
110-
if (pathIndex == TRIE_MAX_HEIGHT - 1) { // collision
110+
if (node.isCollision()) {
111111
path[pathIndex + 1].reset(node.buffer, node.buffer.size)
112112
} else {
113113
path[pathIndex + 1].reset(node.buffer, ENTRY_SIZE * node.entryCount())

0 commit comments

Comments
 (0)