From a8ea6376bc5eae78557b8d91a13a529b2728fe5b Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Sun, 27 Sep 2020 22:09:23 -0400 Subject: [PATCH] Small cleanup --- indra/llcommon/llstring.cpp | 12 +++++------- indra/llcommon/llstring.h | 5 +++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index fc157f6d28a..4d63492a4ed 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -932,7 +932,7 @@ boost::optional<std::string> llstring_getoptenv(const std::string& key) long LLStringOps::sPacificTimeOffset = 0; long LLStringOps::sLocalTimeOffset = 0; bool LLStringOps::sPacificDaylightTime = 0; -std::map<std::string, std::string> LLStringOps::datetimeToCodes; +absl::flat_hash_map<std::string, std::string> LLStringOps::datetimeToCodes; std::vector<std::string> LLStringOps::sWeekDayList; std::vector<std::string> LLStringOps::sWeekDayShortList; @@ -1041,18 +1041,16 @@ void LLStringOps::setupDayFormat(const std::string& data) } -std::string LLStringOps::getDatetimeCode (std::string key) +std::string LLStringOps::getDatetimeCode (std::string_view key) { - std::map<std::string, std::string>::iterator iter; - - iter = datetimeToCodes.find (key); + auto iter = datetimeToCodes.find (key); if (iter != datetimeToCodes.end()) { return iter->second; } else { - return std::string(""); + return std::string(); } } @@ -1262,7 +1260,7 @@ bool LLStringUtil::simpleReplacement(std::string &replacement, std::string token template<> void LLStringUtil::setLocale(std::string inLocale) { - sLocale = inLocale; + sLocale = std::move(inLocale); }; //static diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 8f7d7785007..be782730d89 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -32,6 +32,7 @@ #pragma GCC diagnostic ignored "-Wdeprecated-copy-dtor" #endif #include <boost/optional/optional.hpp> +#include <absl/container/flat_hash_map.h> #if LL_GNUC #pragma GCC diagnostic pop #endif @@ -157,7 +158,7 @@ class LL_COMMON_API LLStringOps static long sLocalTimeOffset; static bool sPacificDaylightTime; - static std::map<std::string, std::string> datetimeToCodes; + static absl::flat_hash_map<std::string, std::string> datetimeToCodes; public: static std::vector<std::string> sWeekDayList; @@ -214,7 +215,7 @@ class LL_COMMON_API LLStringOps // currently in daylight savings time? static bool getPacificDaylightTime(void) { return sPacificDaylightTime;} - static std::string getDatetimeCode (std::string key); + static std::string getDatetimeCode (std::string_view key); // Express a value like 1234567 as "1.23M" static std::string getReadableNumber(F64 num); -- GitLab