From 4eb10d0c6fc3da2f8bae5ceae85e56097586ca96 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 20 Jan 2016 16:11:47 +1100 Subject: [PATCH] log: remove useless to_string(level_t) --- log.cpp | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/log.cpp b/log.cpp index 8144a962..73a2898b 100644 --- a/log.cpp +++ b/log.cpp @@ -30,35 +30,6 @@ #include -/////////////////////////////////////////////////////////////////////////////// -static void -sanity (util::level_t l) -{ - (void)l; // Consume even in release mode - CHECK (l >= 0 && l < util::NUM_LEVELS); -} - -//----------------------------------------------------------------------------- -static const std::string& -to_string (util::level_t l) -{ - sanity (l); - - static const std::array LEVEL_NAMES ({{ - "EMERGENCY", - "ALERT", - "CRITICAL", - "ERROR", - "WARN", - "NOTICE", - "INFO", - "DEBUG" - }}); - - return LEVEL_NAMES[l]; -} - - /////////////////////////////////////////////////////////////////////////////// static util::level_t to_level (std::string name) @@ -90,8 +61,19 @@ to_level (std::string name) std::ostream& util::operator<< (std::ostream& os, util::level_t l) { - os << to_string (l); - return os; + switch (l) { + case util::EMERGENCY: return os << "EMERGENCY"; + case util::ALERT: return os << "ALERT"; + case util::CRITICAL: return os << "CRITICAL"; + case util::ERROR: return os << "ERROR"; + case util::WARNING: return os << "WARNING"; + case util::NOTICE: return os << "NOTICE"; + case util::INFORMATIONAL: return os << "INFO"; + case util::DEBUG: return os << "DEBUG"; + + default: + unreachable (); + } }