Skip to content

Commit

Permalink
Clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
LuKks committed Aug 8, 2023
1 parent b394e59 commit b7d67ff
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ class TreeNode {
let e = this.keys.length
let c

if (e === 0) {
if (cas && !(await cas(null, node))) {
this.changed = false
return true
}
}

while (s < e) {
const mid = (s + e) >> 1
c = b4a.compare(key.value, await this.getKey(mid))
Expand All @@ -126,6 +119,13 @@ class TreeNode {
else s = mid + 1
}

if (this.keys.length === 0) {
if (cas && !(await cas(null, node))) {
this.changed = false
return true
}
}

const i = c < 0 ? e : s
this.keys.splice(i, 0, key)
if (child) this.children.splice(i + 1, 0, new Child(0, 0, child))
Expand Down

0 comments on commit b7d67ff

Please sign in to comment.