mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-17 19:27:05 +00:00
Use more structured bindings
This commit is contained in:
+6
-6
@@ -727,8 +727,8 @@ static int peek() {
|
|||||||
} else if (c == '{') {
|
} else if (c == '{') {
|
||||||
// If character is an open brace, do symbol interpolation
|
// If character is an open brace, do symbol interpolation
|
||||||
shiftChar();
|
shiftChar();
|
||||||
if (auto interp = readInterpolation(0); interp.first && interp.second) {
|
if (auto [sym, exp] = readInterpolation(0); sym && exp) {
|
||||||
beginExpansion(interp.second, interp.first->name);
|
beginExpansion(exp, sym->name);
|
||||||
}
|
}
|
||||||
// Continue in the next iteration
|
// Continue in the next iteration
|
||||||
} else {
|
} else {
|
||||||
@@ -1240,8 +1240,8 @@ static std::pair<Symbol const *, std::shared_ptr<std::string>> readInterpolation
|
|||||||
// Use `consumeChar()` since `peek()` might expand nested interpolations and recursively
|
// Use `consumeChar()` since `peek()` might expand nested interpolations and recursively
|
||||||
// call `readInterpolation()`, which can cause stack overflow.
|
// call `readInterpolation()`, which can cause stack overflow.
|
||||||
if (consumeChar('{')) {
|
if (consumeChar('{')) {
|
||||||
if (auto interp = readInterpolation(depth + 1); interp.first && interp.second) {
|
if (auto [sym, exp] = readInterpolation(depth + 1); sym && exp) {
|
||||||
beginExpansion(interp.second, interp.first->name);
|
beginExpansion(exp, sym->name);
|
||||||
}
|
}
|
||||||
continue; // Restart, reading from the new buffer
|
continue; // Restart, reading from the new buffer
|
||||||
} else if (int c = peek(); c == EOF || isNewline(c) || c == '"') {
|
} else if (int c = peek(); c == EOF || isNewline(c) || c == '"') {
|
||||||
@@ -1350,8 +1350,8 @@ static void appendCharInLiteral(std::string &str, int c) {
|
|||||||
if (c == '{') {
|
if (c == '{') {
|
||||||
// We'll be exiting the string/character scope, so re-enable expansions
|
// We'll be exiting the string/character scope, so re-enable expansions
|
||||||
lexerState->enableExpansions = true;
|
lexerState->enableExpansions = true;
|
||||||
if (auto interp = readInterpolation(0); interp.second) {
|
if (auto exp = readInterpolation(0).second; exp) {
|
||||||
appendExpandedString(str, *interp.second);
|
appendExpandedString(str, *exp);
|
||||||
}
|
}
|
||||||
lexerState->enableExpansions = false;
|
lexerState->enableExpansions = false;
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user