From 67c1214e3331d449f7b32a333a7055034d4805cb Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 6 Oct 2015 14:50:49 +0100 Subject: [PATCH] Bug 1211100 - Add Vector::infallibleEmplaceBack and use it in JSScript::initScriptCounts() r=nbp --- js/src/jsscript.cpp | 2 +- mfbt/Vector.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index f91f08d1a66..3c8d26b889f 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -1334,7 +1334,7 @@ JSScript::initScriptCounts(JSContext* cx) return false; for (size_t i = 0; i < jumpTargets.length(); i++) - MOZ_ALWAYS_TRUE(base.emplaceBack(pcToOffset(jumpTargets[i]))); + base.infallibleEmplaceBack(pcToOffset(jumpTargets[i])); // Create compartment's scriptCountsMap if necessary. ScriptCountsMap* map = compartment()->scriptCountsMap; diff --git a/mfbt/Vector.h b/mfbt/Vector.h index 7f507ef5c3f..d18bfa70bd5 100644 --- a/mfbt/Vector.h +++ b/mfbt/Vector.h @@ -603,6 +603,12 @@ public: { internalAppend(aBegin, aLength); } + template + void infallibleEmplaceBack(Args&&... aArgs) + { + infallibleGrowByUninitialized(1); + new (&back()) T(Forward(aArgs)...); + } void popBack();