Bug 1378537 - Store PerformanceEntry objects in AutoTArray; r=smaug draft
authorKyle Machulis <kyle@nonpolynomial.com>
Wed, 05 Jul 2017 15:15:08 -0700
changeset 604899 54f3d0401c3dfc2682472a9f96af00cf5cc11400
parent 604271 11755fd63168581e194258d04bb6a7337779ec78
child 636325 d2d934cb027749dd00e763ecc5395426b19991ca
push id67224
push userbmo:kyle@nonpolynomial.com
push dateThu, 06 Jul 2017 17:07:07 +0000
reviewerssmaug
bugs1378537
milestone56.0a1
Bug 1378537 - Store PerformanceEntry objects in AutoTArray; r=smaug Storing PerformanceEntry objects in an AutoTArray (currently sized to match our limit for resource timing entries) should omit some per-entry allocations and give us a small speedup with creating entries in tight loops. MozReview-Commit-ID: LNgVhMn461g
dom/performance/Performance.h
--- a/dom/performance/Performance.h
+++ b/dom/performance/Performance.h
@@ -147,21 +147,24 @@ protected:
   void RunNotificationObserversTask();
   void QueueEntry(PerformanceEntry* aEntry);
 
   DOMHighResTimeStamp RoundTime(double aTime) const;
 
   nsTObserverArray<PerformanceObserver*> mObservers;
 
 private:
-  nsTArray<RefPtr<PerformanceEntry>> mUserEntries;
-  nsTArray<RefPtr<PerformanceEntry>> mResourceEntries;
+  static const uint64_t kDefaultResourceTimingBufferSize = 150;
+
+  // When kDefaultResourceTimingBufferSize is increased or removed, these should
+  // be changed to use SegmentedVector
+  AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mUserEntries;
+  AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mResourceEntries;
 
   uint64_t mResourceTimingBufferSize;
-  static const uint64_t kDefaultResourceTimingBufferSize = 150;
   bool mPendingNotificationObserversTask;
 
   RefPtr<PerformanceService> mPerformanceService;
 };
 
 } // namespace dom
 } // namespace mozilla