From eafc32fd686f499ff40eff31b685420b0f64d099 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Sun, 13 Jul 2025 23:44:18 -0400 Subject: [PATCH] Simplify `switch` with one `case` to `if` --- src/asm/lexer.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 89713ad7..a6e5f276 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -2418,9 +2418,8 @@ Capture lexer_CaptureRept() { Defer reenableExpansions = scopedDisableExpansions(); size_t depth = 0; - int c = EOF; - for (;;) { + for (int c;;) { nextLine(); // We're at line start, so attempt to match a `REPT` or `ENDR` token do { // Discard initial whitespace @@ -2471,27 +2470,19 @@ Capture lexer_CaptureMacro() { Defer reenableExpansions = scopedDisableExpansions(); - int c = EOF; - - for (;;) { + for (int c;;) { nextLine(); // We're at line start, so attempt to match an `ENDM` token do { // Discard initial whitespace c = nextChar(); } while (isWhitespace(c)); // Now, try to match `ENDM` as a **whole** keyword - if (startsIdentifier(c)) { - switch (readIdentifier(c, false).type) { - case T_(POP_ENDM): - endCapture(capture); - // The ENDM has been captured, but we don't want it! - // We know we have read exactly "ENDM", not e.g. an EQUS - capture.span.size -= literal_strlen("ENDM"); - return capture; - - default: - break; - } + if (startsIdentifier(c) && readIdentifier(c, false).type == T_(POP_ENDM)) { + endCapture(capture); + // The ENDM has been captured, but we don't want it! + // We know we have read exactly "ENDM", not e.g. an EQUS + capture.span.size -= literal_strlen("ENDM"); + return capture; } // Just consume characters until EOL or EOF