summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2023-10-10 21:14:50 +0100
committerSadie Powell <sadie@witchery.services>2023-10-11 15:51:52 +0100
commita3241065c55fd2a69e8793b89a5d0b1a957b3fd0 (patch)
tree82f80ce2f3bbbdc1c1ef05fe611093cf0b34eab6 /include
parentdc371aad6d059dbf7f30f6878c680532bedd4146 (diff)
Start migrating to range-based for loops.
Diffstat (limited to 'include')
-rw-r--r--include/anope.h8
-rw-r--r--include/modules/httpd.h18
-rw-r--r--include/modules/ldap.h4
-rw-r--r--include/modules/redis.h4
-rw-r--r--include/modules/sql.h20
-rw-r--r--include/version.cpp4
6 files changed, 29 insertions, 29 deletions
diff --git a/include/anope.h b/include/anope.h
index 121ea716c..22094cf1d 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -254,8 +254,8 @@ namespace Anope
inline string lower() const
{
Anope::string new_string = *this;
- for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = Anope::tolower(new_string[i]);
+ for (auto &chr : new_string)
+ chr = Anope::tolower(chr);
return new_string;
}
@@ -265,8 +265,8 @@ namespace Anope
inline string upper() const
{
Anope::string new_string = *this;
- for (size_type i = 0; i < new_string.length(); ++i)
- new_string[i] = Anope::toupper(new_string[i]);
+ for (auto &chr : new_string)
+ chr = Anope::toupper(chr);
return new_string;
}
diff --git a/include/modules/httpd.h b/include/modules/httpd.h
index 544ba5ccd..207499d3b 100644
--- a/include/modules/httpd.h
+++ b/include/modules/httpd.h
@@ -35,14 +35,14 @@ struct HTTPReply
headers = other.headers;
cookies = other.cookies;
- for (unsigned i = 0; i < other.out.size(); ++i)
- out.push_back(new Data(other.out[i]->buf, other.out[i]->len));
+ for (const auto &datum : other.out)
+ out.push_back(new Data(datum->buf, datum->len));
}
~HTTPReply()
{
- for (unsigned i = 0; i < out.size(); ++i)
- delete out[i];
+ for (const auto *datum : out)
+ delete datum;
out.clear();
}
@@ -196,10 +196,8 @@ namespace HTTPUtils
{
Anope::string encoded;
- for (unsigned i = 0; i < url.length(); ++i)
+ for (const auto c : url)
{
- const char& c = url[i];
-
if (isalnum(c) || c == '.' || c == '-' || c == '*' || c == '_')
encoded += c;
else if (c == ' ')
@@ -215,9 +213,9 @@ namespace HTTPUtils
{
Anope::string dst;
- for (unsigned i = 0; i < src.length(); ++i)
+ for (const auto c : src)
{
- switch (src[i])
+ switch (c)
{
case '<':
dst += "&lt;";
@@ -232,7 +230,7 @@ namespace HTTPUtils
dst += "&amp;";
break;
default:
- dst += src[i];
+ dst += c;
}
}
diff --git a/include/modules/ldap.h b/include/modules/ldap.h
index 8c448668e..34f73f65b 100644
--- a/include/modules/ldap.h
+++ b/include/modules/ldap.h
@@ -42,8 +42,8 @@ struct LDAPAttributes : public std::map<Anope::string, std::vector<Anope::string
const std::vector<Anope::string> keys() const
{
std::vector<Anope::string> k;
- for (const_iterator it = this->begin(), it_end = this->end(); it != it_end; ++it)
- k.push_back(it->first);
+ for (const auto &[key, _] : *this)
+ k.push_back(key);
return k;
}
diff --git a/include/modules/redis.h b/include/modules/redis.h
index d953757f0..f30311f34 100644
--- a/include/modules/redis.h
+++ b/include/modules/redis.h
@@ -32,8 +32,8 @@ namespace Redis
i = 0;
bulk.clear();
multi_bulk_size = 0;
- for (unsigned j = 0; j < multi_bulk.size(); ++j)
- delete multi_bulk[j];
+ for (const auto *reply : multi_bulk)
+ delete reply;
multi_bulk.clear();
}
diff --git a/include/modules/sql.h b/include/modules/sql.h
index ff441302b..607f8bcd9 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -34,32 +34,34 @@ namespace SQL
std::set<Anope::string> KeySet() const override
{
std::set<Anope::string> keys;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- keys.insert(it->first);
+ for (const auto &[key, _] : this->data)
+ keys.insert(key);
return keys;
}
size_t Hash() const override
{
size_t hash = 0;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- if (!it->second->str().empty())
- hash ^= Anope::hash_cs()(it->second->str());
+ for (const auto &[_, value] : this->data)
+ {
+ if (!value->str().empty())
+ hash ^= Anope::hash_cs()(value->str());
+ }
return hash;
}
std::map<Anope::string, std::iostream *> GetData() const
{
std::map<Anope::string, std::iostream *> d;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- d[it->first] = it->second;
+ for (const auto &[key, value] : this->data)
+ d[key] = value;
return d;
}
void Clear()
{
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- delete it->second;
+ for (const auto &[_, value] : this->data)
+ delete value;
this->data.clear();
}
diff --git a/include/version.cpp b/include/version.cpp
index 164e07756..9cb16d78e 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -146,9 +146,9 @@ static bool write_version_h(const std::string &versionh, const std::map<std::str
return false;
fd << "#pragma once" << std::endl;
- for (std::map<std::string, std::string>::const_iterator it = versions.begin(); it != versions.end(); ++it)
+ for (const auto &[key, value] : versions)
{
- fd << "#define " << it->first << " " << it->second << std::endl;
+ fd << "#define " << key << " " << value << std::endl;
}
fd.close();