Skip to content

Commit d27013f

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 1d7d55c commit d27013f

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
@@ -148,19 +148,21 @@ public Object doPreEvaluated(final VirtualFrame frame,
148148

149149
GuardedDispatchNode cache = dispatchCache;
150150

151-
Object rcvr = arguments[0];
152-
153-
while (cache != null) {
154-
try {
155-
if (cache.entryMatches(rcvr)) {
156-
return cache.doPreEvaluated(frame, arguments);
151+
if (cache != null) {
152+
Object rcvr = arguments[0];
153+
154+
do {
155+
try {
156+
if (cache.entryMatches(rcvr)) {
157+
return cache.doPreEvaluated(frame, arguments);
158+
}
159+
} catch (InvalidAssumptionException e) {
160+
CompilerDirectives.transferToInterpreterAndInvalidate();
161+
cache = removeInvalidEntryAndReturnNext(cache);
162+
continue;
157163
}
158-
} catch (InvalidAssumptionException e) {
159-
CompilerDirectives.transferToInterpreterAndInvalidate();
160-
cache = removeInvalidEntryAndReturnNext(cache);
161-
continue;
162-
}
163-
cache = cache.next;
164+
cache = cache.next;
165+
} while (cache != null);
164166
}
165167

166168
CompilerDirectives.transferToInterpreterAndInvalidate();

0 commit comments

Comments
 (0)