Bug 1227396: P11. Add IntervalSet::operator- operand. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 25 Nov 2015 20:46:11 +1100
changeset 274541 ae7df1dfcf43d70ce556bf598fe0013245c1e593
parent 274540 2eb96ce8df526aca2d51f1cb0559bdc4b9b81691
child 274542 349eba21938c8503440a3d38bebbc1c6041f9c8d
push id68621
push userjyavenard@mozilla.com
push dateMon, 30 Nov 2015 00:49:17 +0000
treeherdermozilla-inbound@fd4d78b89cc0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1227396
milestone45.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 1227396: P11. Add IntervalSet::operator- operand. r=gerald Also fix constness.
dom/media/Intervals.h
--- a/dom/media/Intervals.h
+++ b/dom/media/Intervals.h
@@ -396,17 +396,17 @@ public:
 
   SelfType operator+ (const SelfType& aIntervals) const
   {
     SelfType intervals(*this);
     intervals.Add(aIntervals);
     return intervals;
   }
 
-  SelfType operator+ (const ElemType& aInterval)
+  SelfType operator+ (const ElemType& aInterval) const
   {
     SelfType intervals(*this);
     intervals.Add(aInterval);
     return intervals;
   }
 
   friend SelfType operator+ (const ElemType& aInterval,
                              const SelfType& aIntervals)
@@ -437,17 +437,24 @@ public:
   SelfType& operator-= (const SelfType& aIntervals)
   {
     for (const auto& interval : aIntervals.mIntervals) {
       *this -= interval;
     }
     return *this;
   }
 
-  SelfType operator- (const ElemType& aInterval)
+  SelfType operator- (const SelfType& aInterval) const
+  {
+    SelfType intervals(*this);
+    intervals -= aInterval;
+    return intervals;
+  }
+
+  SelfType operator- (const ElemType& aInterval) const
   {
     SelfType intervals(*this);
     intervals -= aInterval;
     return intervals;
   }
 
   // Mutate this IntervalSet to be the union of this and aOther.
   SelfType& Union(const SelfType& aOther)