mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Prefer pre-increment/decrement operators in for loops
This commit is contained in:
@@ -45,7 +45,7 @@ bool forEachChar(Charmap const &charmap, F callback) {
|
||||
if (node.isTerminal() && !callback(nodeIdx, mapping)) {
|
||||
return false;
|
||||
}
|
||||
for (unsigned c = 0; c < std::size(node.next); c++) {
|
||||
for (unsigned c = 0; c < std::size(node.next); ++c) {
|
||||
if (size_t nextIdx = node.next[c]; nextIdx) {
|
||||
prefixes.push({nextIdx, mapping + static_cast<char>(c)});
|
||||
}
|
||||
|
||||
@@ -1068,7 +1068,7 @@ static bool isValidDigit(char c) {
|
||||
}
|
||||
|
||||
static bool checkDigitErrors(char const *digits, size_t n, char const *type) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
char c = digits[i];
|
||||
|
||||
if (!isValidDigit(c)) {
|
||||
@@ -1081,7 +1081,7 @@ static bool checkDigitErrors(char const *digits, size_t n, char const *type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t j = i + 1; j < n; j++) {
|
||||
for (size_t j = i + 1; j < n; ++j) {
|
||||
if (c == digits[j]) {
|
||||
error("Repeated digit for %s constant %s", type, printChar(c));
|
||||
return false;
|
||||
|
||||
@@ -29,14 +29,14 @@ std::shared_ptr<std::string> MacroArgs::getAllArgs() const {
|
||||
|
||||
size_t len = 0;
|
||||
|
||||
for (uint32_t i = shift; i < nbArgs; i++) {
|
||||
for (uint32_t i = shift; i < nbArgs; ++i) {
|
||||
len += args[i]->length() + 1; // 1 for comma
|
||||
}
|
||||
|
||||
auto str = std::make_shared<std::string>();
|
||||
str->reserve(len + 1); // 1 for comma
|
||||
|
||||
for (uint32_t i = shift; i < nbArgs; i++) {
|
||||
for (uint32_t i = shift; i < nbArgs; ++i) {
|
||||
std::shared_ptr<std::string> const &arg = args[i];
|
||||
|
||||
str->append(*arg);
|
||||
|
||||
@@ -332,7 +332,7 @@ void out_WriteObject() {
|
||||
putLong(sectionList.size(), file);
|
||||
|
||||
putLong(fileStackNodes.size(), file);
|
||||
for (auto it = fileStackNodes.begin(); it != fileStackNodes.end(); it++) {
|
||||
for (auto it = fileStackNodes.begin(); it != fileStackNodes.end(); ++it) {
|
||||
FileStackNode const &node = **it;
|
||||
|
||||
writeFileStackNode(node, file);
|
||||
|
||||
@@ -2802,7 +2802,7 @@ static uint32_t strToNum(std::vector<int32_t> const &s) {
|
||||
|
||||
uint32_t r = 0;
|
||||
|
||||
for (uint32_t i = length < 4 ? 0 : length - 4; i < length; i++) {
|
||||
for (uint32_t i = length < 4 ? 0 : length - 4; i < length; ++i) {
|
||||
r <<= 8;
|
||||
r |= static_cast<uint8_t>(s[i]);
|
||||
}
|
||||
@@ -2973,7 +2973,7 @@ static size_t charlenUTF8(std::string const &str) {
|
||||
std::string_view view = str;
|
||||
size_t len;
|
||||
|
||||
for (len = 0; charmap_ConvertNext(view, nullptr); len++) {}
|
||||
for (len = 0; charmap_ConvertNext(view, nullptr); ++len) {}
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -2983,7 +2983,7 @@ static std::string strcharUTF8(std::string const &str, uint32_t idx) {
|
||||
size_t charLen = 1;
|
||||
|
||||
// Advance to starting index in source string.
|
||||
for (uint32_t curIdx = 0; charLen && curIdx < idx; curIdx++) {
|
||||
for (uint32_t curIdx = 0; charLen && curIdx < idx; ++curIdx) {
|
||||
charLen = charmap_ConvertNext(view, nullptr);
|
||||
}
|
||||
|
||||
@@ -3006,7 +3006,7 @@ static std::string charsubUTF8(std::string const &str, uint32_t pos) {
|
||||
size_t charLen = 1;
|
||||
|
||||
// Advance to starting position in source string.
|
||||
for (uint32_t curPos = 1; charLen && curPos < pos; curPos++) {
|
||||
for (uint32_t curPos = 1; charLen && curPos < pos; ++curPos) {
|
||||
charLen = charmap_ConvertNext(view, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -807,7 +807,7 @@ void sect_RelBytes(uint32_t n, std::vector<Expression> const &exprs) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
for (uint32_t i = 0; i < n; ++i) {
|
||||
if (Expression const &expr = exprs[i % exprs.size()]; !expr.isKnown()) {
|
||||
createPatch(PATCHTYPE_BYTE, expr, i);
|
||||
writeByte(0);
|
||||
|
||||
Reference in New Issue
Block a user