X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fexperimental%2Flogging%2FLogLevel.h;h=a3e0e34abf71c6cd8dbba0da8af076e9b916576d;hp=7ce01e66d0dca72da6aefb36b16c0484e537a5e4;hb=7b116ffe3b116ffc3c2089ca0b864ca7ebb1d28c;hpb=53f2f752563152c9b10cfe36030aa871927f795a;ds=sidebyside diff --git a/folly/experimental/logging/LogLevel.h b/folly/experimental/logging/LogLevel.h index 7ce01e66..a3e0e34a 100644 --- a/folly/experimental/logging/LogLevel.h +++ b/folly/experimental/logging/LogLevel.h @@ -84,12 +84,11 @@ enum class LogLevel : uint32_t { * adjusted log level values. */ inline constexpr LogLevel operator+(LogLevel level, uint32_t value) { - auto newValue = static_cast(level) + value; // Cap the result at LogLevel::MAX_LEVEL - if (newValue > static_cast(LogLevel::MAX_LEVEL)) { - return LogLevel::MAX_LEVEL; - } - return static_cast(newValue); + return ((static_cast(level) + value) > + static_cast(LogLevel::MAX_LEVEL)) + ? LogLevel::MAX_LEVEL + : static_cast(static_cast(level) + value); } inline LogLevel& operator+=(LogLevel& level, uint32_t value) { level = level + value; @@ -122,10 +121,7 @@ std::ostream& operator<<(std::ostream& os, LogLevel level); * Returns true if and only if a LogLevel is fatal. */ inline constexpr bool isLogLevelFatal(LogLevel level) { - if (folly::kIsDebug) { - return level >= LogLevel::DFATAL; - } else { - return level >= LogLevel::FATAL; - } + return folly::kIsDebug ? (level >= LogLevel::DFATAL) + : (level >= LogLevel::FATAL); } }