@@ -585,6 +585,16 @@ enum class Level : base::type::EnumType {
585
585
// / @brief Represents unknown level
586
586
Unknown = 1010
587
587
};
588
+ } // namespace el
589
+ namespace std {
590
+ template <> struct hash <el::Level> {
591
+ public:
592
+ std::size_t operator ()(const el::Level& l) const {
593
+ return hash<el::base::type::EnumType>{}(static_cast <el::base::type::EnumType>(l));
594
+ }
595
+ };
596
+ }
597
+ namespace el {
588
598
// / @brief Static class that contains helper functions for el::Level
589
599
class LevelHelper : base::StaticClass {
590
600
public:
@@ -1302,7 +1312,7 @@ class CommandLineArgs {
1302
1312
private:
1303
1313
int m_argc;
1304
1314
char ** m_argv;
1305
- std::map <std::string, std::string> m_paramsWithValue;
1315
+ std::unordered_map <std::string, std::string> m_paramsWithValue;
1306
1316
std::vector<std::string> m_params;
1307
1317
};
1308
1318
// / @brief Abstract registry (aka repository) that provides basic interface for pointer repository specified by T_Ptr type.
@@ -1427,7 +1437,7 @@ class AbstractRegistry : public base::threading::ThreadSafe {
1427
1437
// / of AbstractRegistry<T_Ptr, Container>. Any implementation of this class should be
1428
1438
// / explicitly (by using lock functions)
1429
1439
template <typename T_Ptr, typename T_Key = const char *>
1430
- class Registry : public AbstractRegistry <T_Ptr, std::map <T_Key, T_Ptr*>> {
1440
+ class Registry : public AbstractRegistry <T_Ptr, std::unordered_map <T_Key, T_Ptr*>> {
1431
1441
public:
1432
1442
typedef typename Registry<T_Ptr, T_Key>::iterator iterator;
1433
1443
typedef typename Registry<T_Ptr, T_Key>::const_iterator const_iterator;
@@ -1491,7 +1501,7 @@ class Registry : public AbstractRegistry<T_Ptr, std::map<T_Key, T_Ptr*>> {
1491
1501
}
1492
1502
1493
1503
private:
1494
- virtual void deepCopy (const AbstractRegistry<T_Ptr, std::map <T_Key, T_Ptr*>>& sr) ELPP_FINAL {
1504
+ virtual void deepCopy (const AbstractRegistry<T_Ptr, std::unordered_map <T_Key, T_Ptr*>>& sr) ELPP_FINAL {
1495
1505
for (const_iterator it = sr.cbegin (); it != sr.cend (); ++it) {
1496
1506
registerNew (it->first , new T_Ptr (*it->second ));
1497
1507
}
@@ -1591,7 +1601,7 @@ class RegistryWithPred : public AbstractRegistry<T_Ptr, std::vector<T_Ptr*>> {
1591
1601
class Utils {
1592
1602
public:
1593
1603
template <typename T, typename TPtr>
1594
- static bool installCallback (const std::string& id, std::map <std::string, TPtr>* mapT) {
1604
+ static bool installCallback (const std::string& id, std::unordered_map <std::string, TPtr>* mapT) {
1595
1605
if (mapT->find (id) == mapT->end ()) {
1596
1606
mapT->insert (std::make_pair (id, TPtr (new T ())));
1597
1607
return true ;
@@ -1600,15 +1610,15 @@ class Utils {
1600
1610
}
1601
1611
1602
1612
template <typename T, typename TPtr>
1603
- static void uninstallCallback (const std::string& id, std::map <std::string, TPtr>* mapT) {
1613
+ static void uninstallCallback (const std::string& id, std::unordered_map <std::string, TPtr>* mapT) {
1604
1614
if (mapT->find (id) != mapT->end ()) {
1605
1615
mapT->erase (id);
1606
1616
}
1607
1617
}
1608
1618
1609
1619
template <typename T, typename TPtr>
1610
- static T* callback (const std::string& id, std::map <std::string, TPtr>* mapT) {
1611
- typename std::map <std::string, TPtr>::iterator iter = mapT->find (id);
1620
+ static T* callback (const std::string& id, std::unordered_map <std::string, TPtr>* mapT) {
1621
+ typename std::unordered_map <std::string, TPtr>::iterator iter = mapT->find (id);
1612
1622
if (iter != mapT->end ()) {
1613
1623
return static_cast <T*>(iter->second .get ());
1614
1624
}
@@ -1953,7 +1963,7 @@ class Configurations : public base::utils::RegistryWithPred<Configuration, Confi
1953
1963
1954
1964
namespace base {
1955
1965
typedef std::shared_ptr<base::type::fstream_t > FileStreamPtr;
1956
- typedef std::map <std::string, FileStreamPtr> LogStreamsReferenceMap;
1966
+ typedef std::unordered_map <std::string, FileStreamPtr> LogStreamsReferenceMap;
1957
1967
// / @brief Configurations with data types.
1958
1968
// /
1959
1969
// / @detail el::Configurations have string based values. This is whats used internally in order to read correct configurations.
@@ -1990,16 +2000,16 @@ class TypedConfigurations : public base::threading::ThreadSafe {
1990
2000
1991
2001
private:
1992
2002
Configurations* m_configurations;
1993
- std::map <Level, bool > m_enabledMap;
1994
- std::map <Level, bool > m_toFileMap;
1995
- std::map <Level, std::string> m_filenameMap;
1996
- std::map <Level, bool > m_toStandardOutputMap;
1997
- std::map <Level, base::LogFormat> m_logFormatMap;
1998
- std::map <Level, base::SubsecondPrecision> m_subsecondPrecisionMap;
1999
- std::map <Level, bool > m_performanceTrackingMap;
2000
- std::map <Level, base::FileStreamPtr> m_fileStreamMap;
2001
- std::map <Level, std::size_t > m_maxLogFileSizeMap;
2002
- std::map <Level, std::size_t > m_logFlushThresholdMap;
2003
+ std::unordered_map <Level, bool > m_enabledMap;
2004
+ std::unordered_map <Level, bool > m_toFileMap;
2005
+ std::unordered_map <Level, std::string> m_filenameMap;
2006
+ std::unordered_map <Level, bool > m_toStandardOutputMap;
2007
+ std::unordered_map <Level, base::LogFormat> m_logFormatMap;
2008
+ std::unordered_map <Level, base::SubsecondPrecision> m_subsecondPrecisionMap;
2009
+ std::unordered_map <Level, bool > m_performanceTrackingMap;
2010
+ std::unordered_map <Level, base::FileStreamPtr> m_fileStreamMap;
2011
+ std::unordered_map <Level, std::size_t > m_maxLogFileSizeMap;
2012
+ std::unordered_map <Level, std::size_t > m_logFlushThresholdMap;
2003
2013
base::LogStreamsReferenceMap* m_logStreamsReference;
2004
2014
2005
2015
friend class el ::Helpers;
@@ -2009,21 +2019,21 @@ class TypedConfigurations : public base::threading::ThreadSafe {
2009
2019
friend class el ::base::LogDispatcher;
2010
2020
2011
2021
template <typename Conf_T>
2012
- inline Conf_T getConfigByVal (Level level, const std::map <Level, Conf_T>* confMap, const char * confName) {
2022
+ inline Conf_T getConfigByVal (Level level, const std::unordered_map <Level, Conf_T>* confMap, const char * confName) {
2013
2023
base::threading::ScopedLock scopedLock (lock ());
2014
2024
return unsafeGetConfigByVal (level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
2015
2025
}
2016
2026
2017
2027
template <typename Conf_T>
2018
- inline Conf_T& getConfigByRef (Level level, std::map <Level, Conf_T>* confMap, const char * confName) {
2028
+ inline Conf_T& getConfigByRef (Level level, std::unordered_map <Level, Conf_T>* confMap, const char * confName) {
2019
2029
base::threading::ScopedLock scopedLock (lock ());
2020
2030
return unsafeGetConfigByRef (level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
2021
2031
}
2022
2032
2023
2033
template <typename Conf_T>
2024
- Conf_T unsafeGetConfigByVal (Level level, const std::map <Level, Conf_T>* confMap, const char * confName) {
2034
+ Conf_T unsafeGetConfigByVal (Level level, const std::unordered_map <Level, Conf_T>* confMap, const char * confName) {
2025
2035
ELPP_UNUSED (confName);
2026
- typename std::map <Level, Conf_T>::const_iterator it = confMap->find (level);
2036
+ typename std::unordered_map <Level, Conf_T>::const_iterator it = confMap->find (level);
2027
2037
if (it == confMap->end ()) {
2028
2038
try {
2029
2039
return confMap->at (Level::Global);
@@ -2038,9 +2048,9 @@ class TypedConfigurations : public base::threading::ThreadSafe {
2038
2048
}
2039
2049
2040
2050
template <typename Conf_T>
2041
- Conf_T& unsafeGetConfigByRef (Level level, std::map <Level, Conf_T>* confMap, const char * confName) {
2051
+ Conf_T& unsafeGetConfigByRef (Level level, std::unordered_map <Level, Conf_T>* confMap, const char * confName) {
2042
2052
ELPP_UNUSED (confName);
2043
- typename std::map <Level, Conf_T>::iterator it = confMap->find (level);
2053
+ typename std::unordered_map <Level, Conf_T>::iterator it = confMap->find (level);
2044
2054
if (it == confMap->end ()) {
2045
2055
try {
2046
2056
return confMap->at (Level::Global);
@@ -2054,14 +2064,14 @@ class TypedConfigurations : public base::threading::ThreadSafe {
2054
2064
}
2055
2065
2056
2066
template <typename Conf_T>
2057
- void setValue (Level level, const Conf_T& value, std::map <Level, Conf_T>* confMap, bool includeGlobalLevel = true ) {
2067
+ void setValue (Level level, const Conf_T& value, std::unordered_map <Level, Conf_T>* confMap, bool includeGlobalLevel = true ) {
2058
2068
// If map is empty and we are allowed to add into generic level (Level::Global), do it!
2059
2069
if (confMap->empty () && includeGlobalLevel) {
2060
2070
confMap->insert (std::make_pair (Level::Global, value));
2061
2071
return ;
2062
2072
}
2063
2073
// If same value exist in generic level already, dont add it to explicit level
2064
- typename std::map <Level, Conf_T>::iterator it = confMap->find (Level::Global);
2074
+ typename std::unordered_map <Level, Conf_T>::iterator it = confMap->find (Level::Global);
2065
2075
if (it != confMap->end () && it->second == value) {
2066
2076
return ;
2067
2077
}
@@ -2360,7 +2370,7 @@ inline void FUNCTION_NAME(const T&);
2360
2370
std::string m_parentApplicationName;
2361
2371
bool m_isConfigured;
2362
2372
Configurations m_configurations;
2363
- std::map <Level, unsigned int > m_unflushedCount;
2373
+ std::unordered_map <Level, unsigned int > m_unflushedCount;
2364
2374
base::LogStreamsReferenceMap* m_logStreamsReference;
2365
2375
LogBuilderPtr m_logBuilder;
2366
2376
@@ -2466,7 +2476,7 @@ class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
2466
2476
LogBuilderPtr m_defaultLogBuilder;
2467
2477
Configurations m_defaultConfigurations;
2468
2478
base::LogStreamsReferenceMap m_logStreamsReference;
2469
- std::map <std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
2479
+ std::unordered_map <std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
2470
2480
friend class el ::base::Storage;
2471
2481
2472
2482
void unsafeFlushAll (void );
@@ -2492,7 +2502,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
2492
2502
2493
2503
bool allowed (base::type::VerboseLevel vlevel, const char * file);
2494
2504
2495
- inline const std::map <std::string, base::type::VerboseLevel>& modules (void ) const {
2505
+ inline const std::unordered_map <std::string, base::type::VerboseLevel>& modules (void ) const {
2496
2506
return m_modules;
2497
2507
}
2498
2508
@@ -2506,7 +2516,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
2506
2516
private:
2507
2517
base::type::VerboseLevel m_level;
2508
2518
base::type::EnumType* m_pFlags;
2509
- std::map <std::string, base::type::VerboseLevel> m_modules;
2519
+ std::unordered_map <std::string, base::type::VerboseLevel> m_modules;
2510
2520
};
2511
2521
} // namespace base
2512
2522
class LogMessage {
@@ -2740,7 +2750,7 @@ class Storage : base::NoCopy {
2740
2750
2741
2751
inline std::string getThreadName (const std::string& threadId) {
2742
2752
base::threading::ScopedLock scopedLock (m_threadNamesLock);
2743
- std::map <std::string, std::string>::const_iterator it = m_threadNames.find (threadId);
2753
+ std::unordered_map <std::string, std::string>::const_iterator it = m_threadNames.find (threadId);
2744
2754
if (it == m_threadNames.end ()) {
2745
2755
return threadId;
2746
2756
}
@@ -2757,9 +2767,9 @@ class Storage : base::NoCopy {
2757
2767
#endif // ELPP_ASYNC_LOGGING
2758
2768
base::utils::CommandLineArgs m_commandLineArgs;
2759
2769
PreRollOutCallback m_preRollOutCallback;
2760
- std::map <std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
2761
- std::map <std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
2762
- std::map <std::string, std::string> m_threadNames;
2770
+ std::unordered_map <std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
2771
+ std::unordered_map <std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
2772
+ std::unordered_map <std::string, std::string> m_threadNames;
2763
2773
std::vector<CustomFormatSpecifier> m_customFormatSpecifiers;
2764
2774
base::threading::Mutex m_customFormatSpecifiersLock;
2765
2775
base::threading::Mutex m_threadNamesLock;
0 commit comments