Bug 1353618 - Optimize storage of MozPromise::mThenValues. r=gerald

1. Set the capacity to 1 when IsExclusive is true.
2. Set it to 3 because Try shows we never have more the 3 elements when IsExclusive is false.

MozReview-Commit-ID: dmIeE6ZTeh

--HG--
extra : rebase_source : fc6b173d3a389d11424238f76cbae1f496155ba5
extra : source : c6203c27b8020999ed39ff43ddf5173f5111ef6b
This commit is contained in:
JW Wang 2017-03-31 18:41:29 +08:00
parent c7495b1957
commit 4cff3416a0

View File

@ -926,7 +926,9 @@ protected:
#ifdef PROMISE_DEBUG
uint32_t mMagic1 = sMagic;
#endif
nsTArray<RefPtr<ThenValueBase>> mThenValues;
// Try shows we never have more than 3 elements when IsExclusive is false.
// So '3' is a good value to avoid heap allocation in most cases.
AutoTArray<RefPtr<ThenValueBase>, IsExclusive ? 1 : 3> mThenValues;
#ifdef PROMISE_DEBUG
uint32_t mMagic2 = sMagic;
#endif