Skip to content

Commit a0c3465

Browse files
authored
Use short-circuit && in Exchange.removeKeyRangeInternal (CodeQL java/non-short-circuit-evaluation) (#245)
The anti-value guard combined removeOnlyAntiValue with the isKeyRangeAntiValue check using the non-short-circuit & operator, so isKeyRangeAntiValue was always evaluated even when removeOnlyAntiValue was false. isKeyRangeAntiValue only reads buffer state and has no side effects, so switching to && is behaviour-preserving and skips the redundant call when the flag is already false.
1 parent 77e436c commit a0c3465

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

persistit/core/src/main/java/com/persistit/Exchange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3700,7 +3700,7 @@ boolean raw_removeKeyRangeInternal(final Key key1, final Key key2, final boolean
37003700

37013701
LevelCache lc = _levelCache[0];
37023702
if (removeOnlyAntiValue
3703-
& !isKeyRangeAntiValue(lc._leftBuffer, lc._leftFoundAt, lc._rightBuffer, lc._rightFoundAt)) {
3703+
&& !isKeyRangeAntiValue(lc._leftBuffer, lc._leftFoundAt, lc._rightBuffer, lc._rightFoundAt)) {
37043704
result = false;
37053705
break;
37063706
}

0 commit comments

Comments
 (0)