aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-06-20 14:02:12 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-06-20 14:02:12 -0500
commit4aa832e534316614c3fe68897fb18862ab7e1164 (patch)
treed2efe90c8e7524c4bf0b6ebd3526b90611102346 /external
parentMerge pull request #3878 (diff)
parenteasylogging++: cached allowed categories (diff)
downloadmonero-4aa832e534316614c3fe68897fb18862ab7e1164.tar.xz
Merge pull request #3702
099bb83 easylogging++: cached allowed categories (moneromooo-monero)
Diffstat (limited to 'external')
-rw-r--r--external/easylogging++/easylogging++.cc11
-rw-r--r--external/easylogging++/easylogging++.h2
2 files changed, 12 insertions, 1 deletions
diff --git a/external/easylogging++/easylogging++.cc b/external/easylogging++/easylogging++.cc
index 212a1822d..8a5dc91e9 100644
--- a/external/easylogging++/easylogging++.cc
+++ b/external/easylogging++/easylogging++.cc
@@ -1967,10 +1967,12 @@ void VRegistry::setCategories(const char* categories, bool clear) {
base::threading::ScopedLock scopedLock(lock());
auto insert = [&](std::stringstream& ss, Level level) {
m_categories.push_back(std::make_pair(ss.str(), level));
+ m_cached_allowed_categories.clear();
};
if (clear) {
m_categories.clear();
+ m_cached_allowed_categories.clear();
m_categoriesString.clear();
}
if (!m_categoriesString.empty())
@@ -2033,15 +2035,22 @@ static int priority(Level level) {
bool VRegistry::allowed(Level level, const char* category) {
base::threading::ScopedLock scopedLock(lock());
+ const std::string scategory = category;
+ const std::map<std::string, int>::const_iterator it = m_cached_allowed_categories.find(scategory);
+ if (it != m_cached_allowed_categories.end())
+ return priority(level) <= it->second;
if (m_categories.empty() || category == nullptr) {
return false;
} else {
std::deque<std::pair<std::string, Level>>::const_reverse_iterator it = m_categories.rbegin();
for (; it != m_categories.rend(); ++it) {
if (base::utils::Str::wildCardMatch(category, it->first.c_str())) {
- return priority(level) <= priority(it->second);
+ const int p = priority(it->second);
+ m_cached_allowed_categories.insert(std::make_pair(std::move(scategory), p));
+ return priority(level) <= p;
}
}
+ m_cached_allowed_categories.insert(std::make_pair(std::move(scategory), -1));
return false;
}
}
diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h
index 3270bd607..6b8b4fc35 100644
--- a/external/easylogging++/easylogging++.h
+++ b/external/easylogging++/easylogging++.h
@@ -2485,6 +2485,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
inline void clearCategories(void) {
base::threading::ScopedLock scopedLock(lock());
m_categories.clear();
+ m_cached_allowed_categories.clear();
}
inline void clearModules(void) {
@@ -2526,6 +2527,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
base::type::EnumType* m_pFlags;
std::map<std::string, base::type::VerboseLevel> m_modules;
std::deque<std::pair<std::string, Level>> m_categories;
+ std::map<std::string, int> m_cached_allowed_categories;
std::string m_categoriesString;
std::string m_filenameCommonPrefix;
};