Bug 1385369 - Reserve 1 space in Selection::mRanges; r=qdot
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 28 Jul 2017 13:24:51 -0400
changeset 420564 07320f178c144b1a4be67400e2168e04677edec0
parent 420563 1ba4cfc4fa6289f4ba92886099c131ed85edd8fd
child 420565 b5cbc88dede0b871548513e0d2d10b4c9d05178f
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1385369
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1385369 - Reserve 1 space in Selection::mRanges; r=qdot Most selections on the Web end up with one Range inside them. By reserving the space for this one range inline, we can avoid the allocator pressure in a lot of hot code when manipulating the Selection object.
dom/base/Selection.h
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -432,17 +432,17 @@ private:
   // us to perform binary searches when searching for existence of a range,
   // giving us O(log n) search time.
   //
   // Inserting a new range requires finding the overlapping interval, requiring
   // two binary searches plus up to an additional 6 DOM comparisons. If this
   // proves to be a performance concern, then an interval tree may be a
   // possible solution, allowing the calculation of the overlap interval in
   // O(log n) time, though this would require rebalancing and other overhead.
-  nsTArray<RangeData> mRanges;
+  AutoTArray<RangeData, 1> mRanges;
 
   RefPtr<nsRange> mAnchorFocusRange;
   RefPtr<nsFrameSelection> mFrameSelection;
   RefPtr<nsAutoScrollTimer> mAutoScrollTimer;
   FallibleTArray<nsCOMPtr<nsISelectionListener>> mSelectionListeners;
   nsRevocableEventPtr<ScrollSelectionIntoViewEvent> mScrollEvent;
   CachedOffsetForFrame* mCachedOffsetForFrame;
   nsDirection mDirection;