From f1c0aa73718ab7c7bb32cb625e13cec3385ac6cd Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Fri, 4 Mar 2016 12:06:06 -0500 Subject: [PATCH] Bug 1170045 - part 2 - use SegmentedVector in the DeferredFinalize implementation; r=mccr8 This change ought to make the necessary allocations for many deferred finalizations smaller, at the cost of some extra space usage and slightly slower walking over the array. --- dom/bindings/BindingUtils.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index afe626cd2823..86706766edc5 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -24,6 +24,7 @@ #include "mozilla/dom/NonRefcountedDOMObject.h" #include "mozilla/dom/Nullable.h" #include "mozilla/dom/RootedDictionary.h" +#include "mozilla/SegmentedVector.h" #include "mozilla/dom/workers/Workers.h" #include "mozilla/ErrorResult.h" #include "mozilla/Likely.h" @@ -2849,27 +2850,27 @@ struct DeferredFinalizerImpl typename Conditional::value, RefPtr, nsAutoPtr>::Type>::Type SmartPtr; - typedef nsTArray SmartPtrArray; + typedef SegmentedVector SmartPtrArray; static_assert(IsSame::value || !IsBaseOf::value, "nsISupports classes should all use the nsISupports instantiation"); static inline void - AppendAndTake(nsTArray>& smartPtrArray, nsISupports* ptr) + AppendAndTake(SegmentedVector>& smartPtrArray, nsISupports* ptr) { - smartPtrArray.AppendElement(dont_AddRef(ptr)); + smartPtrArray.InfallibleAppend(dont_AddRef(ptr)); } template static inline void - AppendAndTake(nsTArray>& smartPtrArray, U* ptr) + AppendAndTake(SegmentedVector>& smartPtrArray, U* ptr) { - smartPtrArray.AppendElement(dont_AddRef(ptr)); + smartPtrArray.InfallibleAppend(dont_AddRef(ptr)); } template static inline void - AppendAndTake(nsTArray>& smartPtrArray, U* ptr) + AppendAndTake(SegmentedVector>& smartPtrArray, U* ptr) { - smartPtrArray.AppendElement(ptr); + smartPtrArray.InfallibleAppend(ptr); } static void* @@ -2892,7 +2893,7 @@ struct DeferredFinalizerImpl aSlice = oldLen; } uint32_t newLen = oldLen - aSlice; - pointers->RemoveElementsAt(newLen, aSlice); + pointers->PopLastN(aSlice); if (newLen == 0) { delete pointers; return true;