Simplify switch with one case to if

This commit is contained in:
Rangi42
2025-07-13 23:44:18 -04:00
parent 2adeda0318
commit eafc32fd68

View File

@@ -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):
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;
default:
break;
}
}
// Just consume characters until EOL or EOF