Remove utils::hasKey(), as we now have .contains()

This commit is contained in:
Albert S. 2021-10-19 12:48:45 +02:00
orang tua d035579da7
melakukan 873401694e
3 mengubah file dengan 3 tambahan dan 9 penghapusan

Melihat File

@ -21,7 +21,7 @@ Authenticator::Authenticator(UserDao &userDao)
// TODO: make failure counter configurable
bool Authenticator::isBanned(std::string ip)
{
if(utils::hasKey(loginFails, ip))
if(loginFails.contains(ip))
{
LoginFail &fl = loginFails[ip];
std::lock_guard<std::mutex> lock(fl.mutex);

Melihat File

@ -20,12 +20,6 @@ std::string strreplace(std::string str, const std::string &search, const std::st
std::string html_xss(std::string_view str);
std::string getenv(const std::string &key);
template <class T, class U> bool hasKey(const std::map<T, U> &map, const T &key)
{
auto k = map.find(key);
return k != map.end();
}
template <class T, class U> U getKeyOrEmpty(const std::map<T, U> &map, const T &key)
{
auto k = map.find(key);

Melihat File

@ -60,12 +60,12 @@ std::string Varreplacer::makeReplacement(std::string_view varkeyvalue)
std::string_view value;
std::tie(key, value) = extractKeyAndValue(varkeyvalue);
if(utils::hasKey(keyValues, key))
if(keyValues.contains(key))
{
std::string replacementContent = keyValues[key];
return replacementContent;
}
else if(utils::hasKey(resolverFunctionsMap, key))
else if(resolverFunctionsMap.contains(key))
{
auto resolver = this->resolverFunctionsMap[key];