Bug 1190472 - part 3 - optimize pushing an entire queue onto MediaRawDataQueue; r=kinetik
authorNathan Froyd <froydnj@mozilla.com>
Thu, 01 Oct 2015 19:06:50 -0400
changeset 268639 0e80a5538a674f3d82aed52d52dd4fbefa074820
parent 268638 3c4316e8d12a65200a4dde956cb67a51e87097ce
child 268640 4e7598ff5a9f9a5adfb494d38a90943fcb6821b3
push id29559
push usercbook@mozilla.com
push dateWed, 21 Oct 2015 13:33:00 +0000
treeherdermozilla-central@473aefe5bd85 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1190472
milestone44.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 1190472 - part 3 - optimize pushing an entire queue onto MediaRawDataQueue; r=kinetik In the one place we push a MediaRawDataQueue onto a MediaRawDataQueue, we don't use the pushee aftewards. It's more efficient to indicate that by using Move(), and we can then save on reference-counting things needlessly.
dom/media/webm/WebMDemuxer.cpp
dom/media/webm/WebMDemuxer.h
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -903,17 +903,17 @@ WebMTrackDemuxer::SetNextKeyFrameTime()
     } else if (!foundKeyframe &&
                sampleTimecode > startTime.ref() + MAX_LOOK_AHEAD) {
       WEBM_DEBUG("Couldn't find keyframe in a reasonable time, aborting");
       break;
     }
   }
   // We may have demuxed more than intended, so ensure that all frames are kept
   // in the right order.
-  mSamples.PushFront(skipSamplesQueue);
+  mSamples.PushFront(Move(skipSamplesQueue));
 
   if (frameTime != -1) {
     mNextKeyframeTime.emplace(media::TimeUnit::FromMicroseconds(frameTime));
     WEBM_DEBUG("Next Keyframe %f (%u queued %.02fs)",
                mNextKeyframeTime.value().ToSeconds(),
                uint32_t(mSamples.GetSize()),
                media::TimeUnit::FromMicroseconds(mSamples.Last()->mTimecode - mSamples.First()->mTimecode).ToSeconds());
   } else {
--- a/dom/media/webm/WebMDemuxer.h
+++ b/dom/media/webm/WebMDemuxer.h
@@ -35,18 +35,20 @@ class MediaRawDataQueue {
   void PushFront(MediaRawData* aItem) {
     mQueue.push_front(aItem);
   }
 
   void PushFront(already_AddRefed<MediaRawData>&& aItem) {
     mQueue.push_front(Move(aItem));
   }
 
-  void PushFront(const MediaRawDataQueue& aOther) {
-    mQueue.insert(mQueue.begin(), aOther.mQueue.begin(), aOther.mQueue.end());
+  void PushFront(MediaRawDataQueue&& aOther) {
+    while (!aOther.mQueue.empty()) {
+      Push(aOther.PopFront());
+    }
   }
 
   already_AddRefed<MediaRawData> PopFront() {
     RefPtr<MediaRawData> result = mQueue.front().forget();
     mQueue.pop_front();
     return result.forget();
   }