Bug 1371277 - Use reserved space for one item in SelectionState::mArray; r=masayuki
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 08 Jun 2017 10:08:14 -0400
changeset 411277 7680538080d1bc8dd25be592d94ede01145fdb4a
parent 411276 ea0c86248f0aee0133154de3d763917f42748300
child 411278 fd26823c9dc6aaff3dbae97e5d3953564f8664ca
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1371277
milestone55.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 1371277 - Use reserved space for one item in SelectionState::mArray; r=masayuki This avoids dynamic allocations in SelectionState::SaveSelection() in the common case for the selections that only have a maximum of one range stored in them.
editor/libeditor/SelectionState.h
--- a/editor/libeditor/SelectionState.h
+++ b/editor/libeditor/SelectionState.h
@@ -62,17 +62,17 @@ public:
 
   void SaveSelection(dom::Selection *aSel);
   nsresult RestoreSelection(dom::Selection* aSel);
   bool IsCollapsed();
   bool IsEqual(SelectionState *aSelState);
   void MakeEmpty();
   bool IsEmpty();
 private:
-  nsTArray<RefPtr<RangeItem>> mArray;
+  AutoTArray<RefPtr<RangeItem>, 1> mArray;
 
   friend class RangeUpdater;
   friend void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback&,
                                           SelectionState&,
                                           const char*,
                                           uint32_t);
   friend void ImplCycleCollectionUnlink(SelectionState&);
 };