logging: fix compiler compatibility for one more constexpr function
[folly.git] / folly / experimental / logging / LogLevel.h
index 75f401b126dbdd2fbab6bd06b23922b13dcacd4f..a3e0e34abf71c6cd8dbba0da8af076e9b916576d 100644 (file)
@@ -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<uint32_t>(level) + value;
   // Cap the result at LogLevel::MAX_LEVEL
-  if (newValue > static_cast<uint32_t>(LogLevel::MAX_LEVEL)) {
-    return LogLevel::MAX_LEVEL;
-  }
-  return static_cast<LogLevel>(newValue);
+  return ((static_cast<uint32_t>(level) + value) >
+          static_cast<uint32_t>(LogLevel::MAX_LEVEL))
+      ? LogLevel::MAX_LEVEL
+      : static_cast<LogLevel>(static_cast<uint32_t>(level) + value);
 }
 inline LogLevel& operator+=(LogLevel& level, uint32_t value) {
   level = level + value;