Bug 1524890 - P9. Add += and -= operator. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 22 Feb 2019 09:19:18 +0000
changeset 518679 ddc76517c3366c8651038ad3df94ca5eb00d1058
parent 518678 731a0f1e7f215d04e6bf777e9fc3358cb406693c
child 518680 08fd6ddd88e4750923b58fd8af0643a8c8d7507a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1524890
milestone67.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 1524890 - P9. Add += and -= operator. r=gerald Differential Revision: https://phabricator.services.mozilla.com/D20167
dom/media/Intervals.h
--- a/dom/media/Intervals.h
+++ b/dom/media/Intervals.h
@@ -83,26 +83,51 @@ class Interval {
     return SelfType(mStart + aOther.mStart, mEnd + aOther.mEnd,
                     mFuzz + aOther.mFuzz);
   }
 
   SelfType operator+(const T& aVal) const {
     return SelfType(mStart + aVal, mEnd + aVal, mFuzz);
   }
 
-  // Basic interval arithmetic operator definition.
   SelfType operator-(const SelfType& aOther) const {
     return SelfType(mStart - aOther.mEnd, mEnd - aOther.mStart,
                     mFuzz + aOther.mFuzz);
   }
 
   SelfType operator-(const T& aVal) const {
     return SelfType(mStart - aVal, mEnd - aVal, mFuzz);
   }
 
+  SelfType& operator+=(const SelfType& aOther) {
+    mStart += aOther.mStart;
+    mEnd += aOther.mEnd;
+    mFuzz += aOther.mFuzz;
+    return *this;
+  }
+
+  SelfType& operator+=(const T& aVal) {
+    mStart += aVal;
+    mEnd += aVal;
+    return *this;
+  }
+
+  SelfType& operator-=(const SelfType& aOther) {
+    mStart -= aOther.mStart;
+    mEnd -= aOther.mEnd;
+    mFuzz += aOther.mFuzz;
+    return *this;
+  }
+
+  SelfType& operator-=(const T& aVal) {
+    mStart -= aVal;
+    mEnd -= aVal;
+    return *this;
+  }
+
   bool operator==(const SelfType& aOther) const {
     return mStart == aOther.mStart && mEnd == aOther.mEnd;
   }
 
   bool operator!=(const SelfType& aOther) const { return !(*this == aOther); }
 
   bool Contains(const T& aX) const {
     return mStart - mFuzz <= aX && aX < mEnd + mFuzz;
@@ -535,17 +560,16 @@ class IntervalSet {
     for (const auto& interval : mIntervals) {
       if (interval.ContainsWithStrictEnd(aInterval)) {
         return true;
       }
     }
     return false;
   }
 
-
   bool Intersects(const ElemType& aInterval) const {
     for (const auto& interval : mIntervals) {
       if (interval.Intersects(aInterval)) {
         return true;
       }
     }
     return false;
   }