Bug 1385181 - Avoid excess copying when return from HashTable::lookupForAdd(). r=luke

MozReview-Commit-ID: F95DCc1wvkE

--HG--
extra : rebase_source : 42edaf41d53e9c7646206cc6ea9c9ce976846eb1
This commit is contained in:
Ting-Yu Chou 2017-08-01 17:00:39 +08:00
parent 22c17c93c9
commit fe98b4e219

View File

@ -1772,9 +1772,15 @@ class HashTable : private AllocPolicy
if (!EnsureHash<HashPolicy>(l))
return AddPtr();
HashNumber keyHash = prepareHash(l);
Entry& entry = lookup(l, keyHash, sCollisionBit);
AddPtr p(entry, *this, keyHash);
// Calling constructor in return statement here avoid excess copying
// when build with Visual Studio 2015 and 2017, but it triggers a bug in
// gcc which is fixed in gcc-6. See bug 1385181.
#if MOZ_IS_GCC && __GNUC__ < 6
AddPtr p(lookup(l, keyHash, sCollisionBit), *this, keyHash);
return p;
#else
return AddPtr(lookup(l, keyHash, sCollisionBit), *this, keyHash);
#endif
}
template <typename... Args>