Skip to content

Commit

Permalink
perf: avoid new array while insertNode (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
H4ad committed Dec 8, 2023
1 parent 441b86e commit f5180ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/orama/src/trees/avl.ts
Expand Up @@ -211,7 +211,9 @@ export function insert<K, V> (rootNode: RootNode<K, V[]>, key: K, newValue: V[])
} else if (key > node.k) {
node.r = insertNode(node.r, key, newValue)
} else {
node.v = Array.from(new Set([...node.v, ...newValue]))
for (const value of newValue) {
node.v.push(value);
}
return node
}

Expand Down

0 comments on commit f5180ba

Please sign in to comment.