Skip to content

Commit 20b952d

Browse files
committed
Refactor and remove excessive branching
1 parent 88b315f commit 20b952d

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

src/main/java/org/truffleruby/parser/BodyTranslator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,12 +1515,7 @@ public RubyNode visitFlipNode(FlipParseNode node) {
15151515
protected FrameSlotAndDepth createFlipFlopState(SourceIndexLength sourceSection, int depth) {
15161516
final int frameSlot = environment.declareLocalTemp("flipflop");
15171517
environment.getFlipFlopStates().add(frameSlot);
1518-
1519-
if (depth == 0) {
1520-
return new FrameSlotAndDepth(frameSlot, 0);
1521-
} else {
1522-
return new FrameSlotAndDepth(frameSlot, depth);
1523-
}
1518+
return new FrameSlotAndDepth(frameSlot, depth);
15241519
}
15251520

15261521
@Override

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,12 +1527,7 @@ protected RubyNode defaultVisit(Nodes.Node node) {
15271527
protected FindDeclarationVariableNodes.FrameSlotAndDepth createFlipFlopState(int depth) {
15281528
final int frameSlot = environment.declareLocalTemp("flipflop");
15291529
environment.getFlipFlopStates().add(frameSlot);
1530-
1531-
if (depth == 0) {
1532-
return new FindDeclarationVariableNodes.FrameSlotAndDepth(frameSlot, 0);
1533-
} else {
1534-
return new FindDeclarationVariableNodes.FrameSlotAndDepth(frameSlot, depth);
1535-
}
1530+
return new FindDeclarationVariableNodes.FrameSlotAndDepth(frameSlot, depth);
15361531
}
15371532

15381533
/** Translate a list of nodes, e.g. break/return operands, into an array producing node. It returns ArrayLiteralNode

0 commit comments

Comments
 (0)