Commit 8b37be00 authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

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
parent 6b8138f9
...@@ -1106,11 +1106,11 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> { ...@@ -1106,11 +1106,11 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
* Accessors * Accessors
*/ */
constexpr bool hasValue() const noexcept { 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 { constexpr bool hasError() const noexcept {
return expected_detail::Which::eError == this->which_; return UNLIKELY(expected_detail::Which::eError == this->which_);
} }
using Base::uninitializedByException; using Base::uninitializedByException;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment