From: Phil Willoughby Date: Thu, 2 Nov 2017 22:38:42 +0000 (-0700) Subject: Make Expected presume it has a value and not an Error X-Git-Tag: v2017.11.06.00~10 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=8b37be003c80bacd27efc4e0e6d69338d6c0c1eb Make Expected presume it has a value and not an Error Summary: This only affects instruction ordering in GCC-compatible compilers to make the value-having branch preferred. Reviewed By: davidtgoldblatt, nbronson, yfeldblum Differential Revision: D6223188 fbshipit-source-id: 57c69b88eda7ee769912874921c45b47ec7a38de --- diff --git a/folly/Expected.h b/folly/Expected.h index 945797bc..f15010df 100644 --- a/folly/Expected.h +++ b/folly/Expected.h @@ -1106,11 +1106,11 @@ class Expected final : expected_detail::ExpectedStorage { * 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;