Make Expected presume it has a value and not an Error
[folly.git] / folly / Expected.h
index 945797bc5e409252de708e727af14104188ebd4b..f15010dfe821600c58c1221e6739870b743af1f5 100644 (file)
@@ -1106,11 +1106,11 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
    * Accessors
    */
   constexpr bool hasValue() const noexcept {
-    return expected_detail::Which::eValue == this->which_;
+    return LIKELY(expected_detail::Which::eValue == this->which_);
   }
 
   constexpr bool hasError() const noexcept {
-    return expected_detail::Which::eError == this->which_;
+    return UNLIKELY(expected_detail::Which::eError == this->which_);
   }
 
   using Base::uninitializedByException;