mirror of
https://github.com/gbdev/rgbds.git
synced 2026-05-08 10:59:36 +00:00
Keep more non-declaration initialization within the for loop clause
This commit is contained in:
@@ -328,18 +328,16 @@ static void decant(std::vector<AssignedSets> &assignments, std::vector<ColorSet>
|
||||
auto attrs = from.begin();
|
||||
std::advance(attrs, wasProcessed - processed.begin());
|
||||
|
||||
// Build up the "component"; start by marking the first color set as processed
|
||||
std::unordered_set<uint16_t> colors(RANGE(colorSets[attrs->colorSetIndex]));
|
||||
std::vector<size_t> members = {static_cast<size_t>(wasProcessed - processed.begin())};
|
||||
*wasProcessed = true; // Mark the first color set as processed
|
||||
|
||||
// Build up the "component"...
|
||||
for (; ++wasProcessed != processed.end(); ++attrs) {
|
||||
for (*wasProcessed = true; ++wasProcessed != processed.end(); ++attrs) {
|
||||
// If at least one color matches, add it
|
||||
if (ColorSet const &colorSet = colorSets[attrs->colorSetIndex];
|
||||
std::find_first_of(RANGE(colors), RANGE(colorSet)) != colors.end()) {
|
||||
colors.insert(RANGE(colorSet));
|
||||
members.push_back(wasProcessed - processed.begin());
|
||||
*wasProcessed = true; // Mark that color set as processed
|
||||
*wasProcessed = true; // Mark the added color set as processed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -175,8 +175,7 @@ void reverse() {
|
||||
// Pick the smallest width that will result in a landscape-aspect rectangular image.
|
||||
// Thus a prime number of tiles will result in a horizontal row.
|
||||
// This avoids redundancy with `-r 1` which results in a vertical column.
|
||||
width = static_cast<size_t>(ceil(sqrt(mapSize)));
|
||||
for (; width < mapSize; ++width) {
|
||||
for (width = static_cast<size_t>(ceil(sqrt(mapSize))); width < mapSize; ++width) {
|
||||
if (mapSize % width == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
+4
-6
@@ -192,15 +192,16 @@ static yy::parser::symbol_type parseAnyNumber(int c) {
|
||||
|
||||
static yy::parser::symbol_type parseString() {
|
||||
LexerStackEntry &context = lexerStack.back();
|
||||
int c = context.file.sgetc();
|
||||
std::string str;
|
||||
for (; c != '"'; c = context.file.sgetc()) {
|
||||
for (int c = context.file.sgetc();; c = context.file.sgetc()) {
|
||||
if (c == EOF || isNewline(c)) {
|
||||
scriptError("Unterminated string");
|
||||
break;
|
||||
}
|
||||
context.file.sbumpc();
|
||||
if (c == '\\') {
|
||||
if (c == '"') {
|
||||
break;
|
||||
} else if (c == '\\') {
|
||||
c = context.file.sgetc();
|
||||
if (c == EOF || isNewline(c)) {
|
||||
scriptError("Unterminated string");
|
||||
@@ -220,9 +221,6 @@ static yy::parser::symbol_type parseString() {
|
||||
}
|
||||
str.push_back(c);
|
||||
}
|
||||
if (c == '"') {
|
||||
context.file.sbumpc();
|
||||
}
|
||||
return yy::parser::make_string(std::move(str));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user