mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1683227
- Add a note to Maybe::valueOr() about a suboptimal usage. r=sg DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D100071
This commit is contained in:
parent
81777ea3b9
commit
fd531e4c1a
@ -496,6 +496,13 @@ class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Maybe
|
||||
/*
|
||||
* Returns the contents of this Maybe<T> by value. If |isNothing()|, returns
|
||||
* the default value provided.
|
||||
*
|
||||
* Note: If the value passed to aDefault is not the result of a trivial
|
||||
* expression, but expensive to evaluate, e.g. |valueOr(ExpensiveFunction())|,
|
||||
* use |valueOrFrom| instead, e.g.
|
||||
* |valueOrFrom([arg] { return ExpensiveFunction(arg); })|. This ensures
|
||||
* that the expensive expression is only evaluated when its result will
|
||||
* actually be used.
|
||||
*/
|
||||
template <typename V>
|
||||
constexpr T valueOr(V&& aDefault) const {
|
||||
|
Loading…
Reference in New Issue
Block a user