Skip to content

Commit 31e20e0

Browse files
committed
Turn while to do/while to do first check and then read argument only when needed
Signed-off-by: Stefan Marr <[email protected]>
1 parent c2d26d8 commit 31e20e0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/trufflesom/interpreter/nodes/MessageSendNode.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,21 @@ public Object doPreEvaluated(final VirtualFrame frame,
141141

142142
GuardedDispatchNode cache = dispatchCache;
143143

144-
Object rcvr = arguments[0];
145-
146-
while (cache != null) {
147-
try {
148-
if (cache.entryMatches(rcvr)) {
149-
return cache.doPreEvaluated(frame, arguments);
144+
if (cache != null) {
145+
Object rcvr = arguments[0];
146+
147+
do {
148+
try {
149+
if (cache.entryMatches(rcvr)) {
150+
return cache.doPreEvaluated(frame, arguments);
151+
}
152+
} catch (InvalidAssumptionException e) {
153+
CompilerDirectives.transferToInterpreterAndInvalidate();
154+
cache = removeInvalidEntryAndReturnNext(cache);
155+
continue;
150156
}
151-
} catch (InvalidAssumptionException e) {
152-
CompilerDirectives.transferToInterpreterAndInvalidate();
153-
cache = removeInvalidEntryAndReturnNext(cache);
154-
continue;
155-
}
156-
cache = cache.next;
157+
cache = cache.next;
158+
} while (cache != null);
157159
}
158160

159161
CompilerDirectives.transferToInterpreterAndInvalidate();

0 commit comments

Comments
 (0)