From 2cdbb145da4b78085ac67ac4f24c87b34b8489e1 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Thu, 27 Feb 2025 14:07:55 -0500 Subject: [PATCH] Avoid use of `goto` in `shiftChar` --- src/asm/lexer.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index d7423701..58337b9a 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -862,22 +862,24 @@ static void shiftChar() { lexerState->macroArgScanDistance--; -restart: - if (!lexerState->expansions.empty()) { - // Advance within the current expansion - if (Expansion &exp = lexerState->expansions.front(); exp.advance()) { - // When advancing would go past an expansion's end, - // move up to its parent and try again to advance - lexerState->expansions.pop_front(); - goto restart; - } - } else { - // Advance within the file contents - if (lexerState->content.holds()) { - lexerState->content.get().offset++; + for (;;) { + if (!lexerState->expansions.empty()) { + // Advance within the current expansion + if (Expansion &exp = lexerState->expansions.front(); exp.advance()) { + // When advancing would go past an expansion's end, + // move up to its parent and try again to advance + lexerState->expansions.pop_front(); + continue; + } } else { - lexerState->content.get().advance(); + // Advance within the file contents + if (lexerState->content.holds()) { + lexerState->content.get().offset++; + } else { + lexerState->content.get().advance(); + } } + return; } } @@ -2114,7 +2116,7 @@ append: } } -finish: +finish: // Can't `break` out of a nested `for`-`switch` // Trim right whitespace auto rightPos = std::find_if_not(str.rbegin(), str.rend(), isWhitespace); str.resize(rightPos.base() - str.begin());