shithub: rgbds

Download patch

ref: 4a73eb56eaa43800f80bdc8f3394c1243ba9abc7
parent: 0f321bc7977ad34c93e1a4857e3a21e6f997f1ad
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Tue Aug 17 14:43:25 EDT 2021

Make `peek()` tail recursive instead of using `goto`

Compilation is identical with `gcc` or `clang`, -O3` or `-O2`

--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -900,11 +900,8 @@
 
 static int peek(void)
 {
-	int c;
+	int c = peekInternal(0);
 
-restart:
-	c = peekInternal(0);
-
 	if (lexerState->macroArgScanDistance > 0)
 		return c;
 
@@ -924,7 +921,7 @@
 			 * expanded, so skip it and keep peeking.
 			 */
 			if (!str || !str[0])
-				goto restart;
+				return peek();
 
 			beginExpansion(str, c == '#', NULL);
 
@@ -945,7 +942,7 @@
 
 		if (str && str[0])
 			beginExpansion(str, false, str);
-		goto restart;
+		return peek();
 	}
 
 	return c;