Skip to content

Commit

Permalink
Use a ternary operator in CNode.insertIf()
Browse files Browse the repository at this point in the history
The if/return check can be simplified into an expression, let's take
advantage of that.

Signed-off-by: Robert Varga <[email protected]>
  • Loading branch information
rovarga committed Jan 25, 2025
1 parent 0b1cfd3 commit 0842609
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions triemap/src/main/java/tech/pantheon/triemap/CNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ boolean insert(final MutableTrieMap<K, V> ct, final INode<K, V> in, final int po
final var cnAtPos = array[pos];
if (cnAtPos instanceof INode<K, V> in) {
// enter next level
if (startGen != in.gen && !renew(ct, parent, startGen)) {
return RESTART;
}
return in.insertIf(ct, startGen, hc, key, val, cond, lev + LEVEL_BITS, parent);
return startGen != in.gen && !renew(ct, parent, startGen)
? RESTART : in.insertIf(ct, startGen, hc, key, val, cond, lev + LEVEL_BITS, parent);
} else if (cnAtPos instanceof SNode<K, V> sn) {
return insertIf(ct, parent, pos, sn, key, val, hc, cond, lev);
} else {
Expand Down

0 comments on commit 0842609

Please sign in to comment.