Skip to content

Commit

Permalink
Reuse temp variables in SwitchCodeGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
pettyjamesm committed May 17, 2024
1 parent 34b8303 commit dac494c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ else if (<value> == <non-constant2>) {

// evaluate the value and store it in a variable
LabelNode nullValue = new LabelNode("nullCondition");
Variable tempVariable = scope.createTempVariable(valueType);
Variable tempVariable = scope.getOrCreateTempVariable(valueType);
BytecodeBlock block = new BytecodeBlock()
.append(valueBytecode)
.append(BytecodeUtils.ifWasNullClearPopAndGoto(scope, nullValue, void.class, valueType))
Expand Down Expand Up @@ -163,6 +163,8 @@ else if (<value> == <non-constant2>) {
.ifFalse(elseValue);
}

return block.append(elseValue);
block.append(elseValue);
scope.releaseTempVariableForReuse(tempVariable);
return block;
}
}

0 comments on commit dac494c

Please sign in to comment.