Bug 1407549 - Make segments allocate chunk storage locally. r?padenot draft
authorAndreas Pehrson <pehrsons@mozilla.com>
Thu, 29 Mar 2018 16:13:36 +0200
changeset 776611 5eafbc17fcf3145a433961a775851c7348a6d92a
parent 776610 931c56f7113f6d4331062f0e2a5b9fc2b30416da
child 776612 9718e6839a85839a191e1aca7a0349ead59ffc6c
push id104925
push userbmo:apehrson@mozilla.com
push dateTue, 03 Apr 2018 13:43:03 +0000
reviewerspadenot
bugs1407549
milestone61.0a1
Bug 1407549 - Make segments allocate chunk storage locally. r?padenot MozReview-Commit-ID: 19VOLomq8A6
dom/media/MediaSegment.h
--- a/dom/media/MediaSegment.h
+++ b/dom/media/MediaSegment.h
@@ -444,22 +444,22 @@ public:
       return nullptr;
     }
     return &mChunks[mChunks.Length() - 1];
   }
 
 protected:
   explicit MediaSegmentBase(Type aType)
     : MediaSegment(aType)
-    , mChunks(DEFAULT_SEGMENT_CAPACITY)
+    , mChunks()
   {}
 
   MediaSegmentBase(MediaSegmentBase&& aSegment)
     : MediaSegment(Move(aSegment))
-    , mChunks(aSegment.mChunks.Capacity())
+    , mChunks()
 #ifdef MOZILLA_INTERNAL_API
     , mTimeStamp(Move(aSegment.mTimeStamp))
 #endif
   {
     mChunks.SwapElements(aSegment.mChunks);
     MOZ_ASSERT(mChunks.Capacity() >= DEFAULT_SEGMENT_CAPACITY,
                "Capacity must be retained in self after swap");
     MOZ_ASSERT(aSegment.mChunks.Capacity() >= DEFAULT_SEGMENT_CAPACITY,
@@ -570,17 +570,17 @@ protected:
     if (i+1 < mChunks.Length()) {
       mChunks.RemoveElementsAt(i+1, mChunks.Length() - (i+1));
     }
     MOZ_ASSERT(mChunks.Capacity() >= DEFAULT_SEGMENT_CAPACITY,
                "Capacity must be retained after removing chunks");
     // Caller must adjust mDuration
   }
 
-  nsTArray<Chunk> mChunks;
+  AutoTArray<Chunk, DEFAULT_SEGMENT_CAPACITY> mChunks;
 #ifdef MOZILLA_INTERNAL_API
   mozilla::TimeStamp mTimeStamp;
 #endif
 };
 
 } // namespace mozilla
 
 #endif /* MOZILLA_MEDIASEGMENT_H_ */