Closed Bug 1332825 Opened 3 years ago Closed 3 years ago

MozPromise::All could Move its given value into place

Categories

(Core :: XPCOM, defect)

49 Branch
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: gerald, Assigned: gerald)

Details

Attachments

(1 file)

MozPromise::All sets up 'Then' lambdas on all promises, that take the resolve/reject object by value. Because of the way 'Then' works with lambdas, there's probably no better way to deal with this for now.

But after that, once a lambda has its local value, it then passes it to the AllPromiseHolder by-value again.
Instead, since this value will not be used again in the lambda, it would be safe to Move it, and from there the MozPromiseHolder::Resolve/Reject could also Move it again into the holder storage, potentially saving two copies per Resolve/Reject.
Comment on attachment 8829085 [details]
Bug 1332825 - Use move semantics in MozPromise::All() and AllPromiseHolder -

https://reviewboard.mozilla.org/r/106282/#review107356
Attachment #8829085 - Flags: review?(jwwang) → review+
Thanks for the reviews today!
Pushed by gsquelart@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8ac365ab3cfb
Use move semantics in MozPromise::All() and AllPromiseHolder - r=jwwang
https://hg.mozilla.org/mozilla-central/rev/8ac365ab3cfb
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.