Commit 943d7d0d authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Simplify WaitUntilObserver::ThenFunction::Call

It was previously doing three ScriptValue copy assignment operator calls:
first from ScriptPromise's promise_ to a temporary object, then to
the value object, and thirdly to the function's return object.

Using return value optimization, the new code only does one copy
assignment: directly to the return object.

It's not a big deal, but that assignment operator is non-trivial,
so we might as well not call it more than necessary.

Bug: none
Change-Id: Idd5544b51a776ac5491c29e0ed5898484135f1ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2512884
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822977}
parent 616c937f
......@@ -93,12 +93,13 @@ class WaitUntilObserver::ThenFunction final : public ScriptFunction {
event_loop->EnqueueMicrotask(
WTF::Bind(&WaitUntilObserver::OnPromiseRejected,
WrapPersistent(observer_.Get())));
value = ScriptPromise::Reject(GetScriptState(), value).GetScriptValue();
} else {
event_loop->EnqueueMicrotask(
WTF::Bind(&WaitUntilObserver::OnPromiseFulfilled,
WrapPersistent(observer_.Get())));
observer_ = nullptr;
return ScriptPromise::Reject(GetScriptState(), value).GetScriptValue();
}
event_loop->EnqueueMicrotask(
WTF::Bind(&WaitUntilObserver::OnPromiseFulfilled,
WrapPersistent(observer_.Get())));
observer_ = nullptr;
return 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