Bug 1163445: Part4. Add IntervalSet::SetFuzz method. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 18 May 2015 16:13:20 +1000
changeset 244287 0fe9422de17bd3204764ee347915480045641e06
parent 244286 7cc62c82bb10460da898ddcc7bd904b6838c5440
child 244288 24a7f0fda98b2d68efaf5b07d1d56b575e89316a
push id59889
push userjyavenard@mozilla.com
push dateMon, 18 May 2015 06:18:59 +0000
treeherdermozilla-inbound@24a7f0fda98b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1163445
milestone41.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 1163445: Part4. Add IntervalSet::SetFuzz method. r=mattwoodrow Will be required for fuzzy search in MediaSource until full conversion to Interval/IntervalSet.
dom/media/Intervals.h
--- a/dom/media/Intervals.h
+++ b/dom/media/Intervals.h
@@ -188,16 +188,21 @@ public:
     return mEnd - mStart;
   }
 
   bool IsEmpty() const
   {
     return mStart == mEnd;
   }
 
+  void SetFuzz(const T& aFuzz)
+  {
+    mFuzz = aFuzz;
+  }
+
   T mStart;
   T mEnd;
   T mFuzz;
 
 private:
 };
 
 // An IntervalSet in a collection of Intervals. The IntervalSet is always
@@ -500,27 +505,34 @@ public:
       if (interval.ContainsStrict(aX)) {
         return true;
       }
     }
     return false;
   }
 
   // Shift all values by aOffset.
-  void Shift(T aOffset)
+  void Shift(const T& aOffset)
   {
     for (auto& interval : mIntervals) {
       interval.mStart += aOffset;
       interval.mEnd += aOffset;
     }
   }
 
+  void SetFuzz(const T& aFuzz) {
+    for (auto& interval : mIntervals) {
+      interval.SetFuzz(aFuzz);
+    }
+    Normalize();
+  }
+
   static const IndexType NoIndex = IndexType(-1);
 
-  IndexType Find(T aValue) const
+  IndexType Find(const T& aValue) const
   {
     for (IndexType i = 0; i < mIntervals.Length(); i++) {
       if (mIntervals[i].Contains(aValue)) {
         return i;
       }
     }
     return NoIndex;
   }