aboutsummaryrefslogtreecommitdiff
path: root/src/configreader.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-11-11 02:25:06 +0000
committerGravatar Sadie Powell2020-11-11 02:29:36 +0000
commit2d6d47b489d733ca3c29fc2f963d424029fcb929 (patch)
treefa38bdd2dcbebdb126d29482bfb7d5389a10c2d4 /src/configreader.cpp
parentConvert FOREACH_MOD_CUSTOM to a variadic function. (diff)
Add stdalgo::equal_range and switch more stuff to iterator_range.
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r--src/configreader.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index dd99f5b92..f818d997d 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -616,21 +616,21 @@ void ServerConfig::ApplyModules(User* user)
std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag)
{
- auto found = config_data.equal_range(tag);
- if (found.first == found.second)
+ auto tags = stdalgo::equal_range(config_data, tag);
+ if (tags.empty())
return EmptyTag;
- std::shared_ptr<ConfigTag> rv = found.first->second;
- found.first++;
- if (found.first != found.second)
- ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Multiple <" + tag + "> tags found; only first will be used "
- "(first at " + rv->source.str() + "; second at " + found.first->second->source.str() + ")");
- return rv;
+ if (tags.count() > 1)
+ {
+ ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Multiple (%zu) <%s> tags found; only the first will be used (first at %s, last at %s)",
+ tags.count(), tag.c_str(), tags.begin()->second->source.str().c_str(), std::prev(tags.end())->second->source.str().c_str());
+ }
+ return tags.begin()->second;
}
ServerConfig::TagList ServerConfig::ConfTags(const std::string& tag)
{
- return ServerConfig::TagList(config_data.equal_range(tag));
+ return stdalgo::equal_range(config_data, tag);
}
std::string ServerConfig::Escape(const std::string& str)