mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Prefer pre-inc/dec unless post-inc/dec are necessary
This commit is contained in:
@@ -58,7 +58,7 @@ static void assignSection(Section §ion, MemoryLocation const &location) {
|
||||
next->bank = location.bank;
|
||||
}
|
||||
|
||||
nbSectionsToAssign--;
|
||||
--nbSectionsToAssign;
|
||||
|
||||
out_AddSection(section);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
location.address += section.alignMask + 1 + section.alignOfs;
|
||||
} else {
|
||||
// Any location is fine, so, next free block
|
||||
spaceIdx++;
|
||||
++spaceIdx;
|
||||
if (spaceIdx < bankMem.size()) {
|
||||
location.address = bankMem[spaceIdx].address;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
// go forwards until that is no longer the case.
|
||||
while (spaceIdx < bankMem.size()
|
||||
&& location.address >= bankMem[spaceIdx].address + bankMem[spaceIdx].size) {
|
||||
spaceIdx++;
|
||||
++spaceIdx;
|
||||
}
|
||||
|
||||
// Try again with the new location/free space combo
|
||||
@@ -174,7 +174,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
return -1;
|
||||
} else if (scrambleROMX && section.type == SECTTYPE_ROMX && location.bank <= scrambleROMX) {
|
||||
if (location.bank > typeInfo.firstBank) {
|
||||
location.bank--;
|
||||
--location.bank;
|
||||
} else if (scrambleROMX < typeInfo.lastBank) {
|
||||
location.bank = scrambleROMX + 1;
|
||||
} else {
|
||||
@@ -183,7 +183,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
} else if (scrambleWRAMX && section.type == SECTTYPE_WRAMX
|
||||
&& location.bank <= scrambleWRAMX) {
|
||||
if (location.bank > typeInfo.firstBank) {
|
||||
location.bank--;
|
||||
--location.bank;
|
||||
} else if (scrambleWRAMX < typeInfo.lastBank) {
|
||||
location.bank = scrambleWRAMX + 1;
|
||||
} else {
|
||||
@@ -191,14 +191,14 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
}
|
||||
} else if (scrambleSRAM && section.type == SECTTYPE_SRAM && location.bank <= scrambleSRAM) {
|
||||
if (location.bank > typeInfo.firstBank) {
|
||||
location.bank--;
|
||||
--location.bank;
|
||||
} else if (scrambleSRAM < typeInfo.lastBank) {
|
||||
location.bank = scrambleSRAM + 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (location.bank < typeInfo.lastBank) {
|
||||
location.bank++;
|
||||
++location.bank;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -355,11 +355,11 @@ static void categorizeSection(Section §ion) {
|
||||
// Insert section while keeping the list sorted by decreasing size
|
||||
auto pos = sections.begin();
|
||||
while (pos != sections.end() && (*pos)->size > section.size) {
|
||||
pos++;
|
||||
++pos;
|
||||
}
|
||||
sections.insert(pos, §ion);
|
||||
|
||||
nbSectionsToAssign++;
|
||||
++nbSectionsToAssign;
|
||||
}
|
||||
|
||||
void assign_AssignSections() {
|
||||
@@ -395,8 +395,7 @@ void assign_AssignSections() {
|
||||
constraints--) {
|
||||
for (Section *section : unassignedSections[constraints]) {
|
||||
fprintf(stderr, "%c \"%s\"", nbSections == 0 ? ';' : ',', section->name.c_str());
|
||||
nbSections++;
|
||||
if (nbSections == 10) {
|
||||
if (++nbSections == 10) {
|
||||
goto max_out; // Can't `break` out of a nested loop
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ static void parseScrambleSpec(char const *spec) {
|
||||
}
|
||||
|
||||
if (*spec == '=') {
|
||||
spec++; // `strtoul` will skip the whitespace on its own
|
||||
++spec; // `strtoul` will skip the whitespace on its own
|
||||
unsigned long limit;
|
||||
char *endptr;
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
||||
|
||||
sym_AddSymbol(symbol);
|
||||
if (std::holds_alternative<Label>(symbol.data)) {
|
||||
nbSymPerSect[std::get<Label>(symbol.data).sectionID]++;
|
||||
++nbSymPerSect[std::get<Label>(symbol.data).sectionID];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ void out_AddSection(Section const §ion) {
|
||||
// Insert section while keeping the list sorted by increasing org
|
||||
auto pos = bankSections.begin();
|
||||
while (pos != bankSections.end() && (*pos)->org < section.org) {
|
||||
pos++;
|
||||
++pos;
|
||||
}
|
||||
bankSections.insert(pos, §ion);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ static void
|
||||
// Output padding up to the next SECTION
|
||||
while (offset + baseOffset < section->org) {
|
||||
putc(getNextFillByte(), outputFile);
|
||||
offset++;
|
||||
++offset;
|
||||
}
|
||||
|
||||
// Output the section itself
|
||||
@@ -196,7 +196,7 @@ static void
|
||||
if (!disablePadding) {
|
||||
while (offset < size) {
|
||||
putc(getNextFillByte(), outputFile);
|
||||
offset++;
|
||||
++offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,7 +419,7 @@ uint16_t forEachSection(SortedSections const §List, F callback) {
|
||||
: zeroLenSection;
|
||||
used += (*pickedSection)->size;
|
||||
callback(**pickedSection);
|
||||
pickedSection++;
|
||||
++pickedSection;
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ static void printDiag(
|
||||
|
||||
static void incrementErrors() {
|
||||
if (nbErrors != UINT32_MAX) {
|
||||
nbErrors++;
|
||||
++nbErrors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user