Commit 289c79d8 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Access the value directly in Optional::value_or

value_or() called value() to get the value, but that resulted in
executing a redundant CHECK() statement. This is not guaranteed to be
optimised out. Also it is annoying when stepping through in a debugger.

Access the value directly rather than calling value().

Change-Id: I0037abf32e1fe0417ee8083ca8e4ae67c8446de7
Reviewed-on: https://chromium-review.googlesource.com/1110178Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569568}
parent 4f89d11d
......@@ -636,7 +636,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
static_assert(std::is_convertible<U, T>::value,
"U must be convertible to T");
return storage_.is_populated_
? value()
? storage_.value_
: static_cast<T>(std::forward<U>(default_value));
}
......@@ -648,7 +648,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
static_assert(std::is_convertible<U, T>::value,
"U must be convertible to T");
return storage_.is_populated_
? std::move(value())
? std::move(storage_.value_)
: static_cast<T>(std::forward<U>(default_value));
}
......
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