From 2d6d47b489d733ca3c29fc2f963d424029fcb929 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Nov 2020 02:25:06 +0000 Subject: Add stdalgo::equal_range and switch more stuff to iterator_range. --- src/configreader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/configreader.cpp') 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 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 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) -- cgit v1.3.1-10-gc9f91