Fix some bad "for (auto x : y)" usage

This commit is contained in:
Henrik Rydgård committed 2025-04-29 16:46:14 +02:00
1 parent 62e4b2852c
commit dbe6ec80a0
17 files changed
+31 -27

No files matched your search

+3 -3
View File
@@ -36,7 +36,7 @@ bool JsonReader::parse() {
int JsonGet::numChildren() const {
int count = 0;
if (value_.getTag() == JSON_OBJECT || value_.getTag() == JSON_ARRAY) {
for (auto it : value_) {
for (const auto &it : value_) {
(void)it;
count++;
}
@@ -52,7 +52,7 @@ const JsonNode *JsonGet::get(const char *child_name) const {
if (value_.getTag() != JSON_OBJECT) {
return nullptr;
}
for (auto it : value_) {
for (const auto &it : value_) {
if (!strcmp(it->key, child_name)) {
return it;
}
@@ -94,7 +94,7 @@ const char *JsonGet::getStringOr(const char *child_name, const char *default_val
bool JsonGet::getStringVector(std::vector<std::string> *vec) const {
vec->clear();
if (value_.getTag() == JSON_ARRAY) {
for (auto it : value_) {
for (const auto &it : value_) {
if (it->value.getTag() == JSON_STRING) {
vec->push_back(it->value.toString());
}