Bug 1305422 - part 17 - remove size_{forward,backward} from ns{Reading,Writing}Iterator; r=erahm
authorNathan Froyd <froydnj@mozilla.com>
Thu, 29 Sep 2016 22:33:57 -0400
changeset 315888 f933f6215b9d67ab84255642d8ab2cb208f051c1
parent 315887 8ad96d4c9d427e135e51b9dd7af31a9d99782e2c
child 315889 c8c685a95ab025a21c418759f292bc491ab26957
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1305422
milestone52.0a1
Bug 1305422 - part 17 - remove size_{forward,backward} from ns{Reading,Writing}Iterator; r=erahm
xpcom/string/nsStringIterator.h
--- a/xpcom/string/nsStringIterator.h
+++ b/xpcom/string/nsStringIterator.h
@@ -86,37 +86,27 @@ public:
 
   self_type operator--(int)
   {
     self_type result(*this);
     --mPosition;
     return result;
   }
 
-  difference_type size_forward() const
-  {
-    return mEnd - mPosition;
-  }
-
-  difference_type size_backward() const
-  {
-    return mPosition - mStart;
-  }
-
   self_type& advance(difference_type aN)
   {
     if (aN > 0) {
-      difference_type step = XPCOM_MIN(aN, size_forward());
+      difference_type step = XPCOM_MIN(aN, mEnd - mPosition);
 
       NS_ASSERTION(step > 0,
                    "can't advance a reading iterator beyond the end of a string");
 
       mPosition += step;
     } else if (aN < 0) {
-      difference_type step = XPCOM_MAX(aN, -size_backward());
+      difference_type step = XPCOM_MAX(aN, -(mPosition - mStart));
 
       NS_ASSERTION(step < 0,
                    "can't advance (backward) a reading iterator beyond the end of a string");
 
       mPosition += step;
     }
     return *this;
   }
@@ -209,49 +199,39 @@ public:
 
   self_type operator--(int)
   {
     self_type result(*this);
     --mPosition;
     return result;
   }
 
-  difference_type size_forward() const
-  {
-    return mEnd - mPosition;
-  }
-
-  difference_type size_backward() const
-  {
-    return mPosition - mStart;
-  }
-
   self_type& advance(difference_type aN)
   {
     if (aN > 0) {
-      difference_type step = XPCOM_MIN(aN, size_forward());
+      difference_type step = XPCOM_MIN(aN, mEnd - mPosition);
 
       NS_ASSERTION(step > 0,
                    "can't advance a writing iterator beyond the end of a string");
 
       mPosition += step;
     } else if (aN < 0) {
-      difference_type step = XPCOM_MAX(aN, -size_backward());
+      difference_type step = XPCOM_MAX(aN, -(mPosition - mStart));
 
       NS_ASSERTION(step < 0,
                    "can't advance (backward) a writing iterator beyond the end of a string");
 
       mPosition += step;
     }
     return *this;
   }
 
   void write(const value_type* aS, uint32_t aN)
   {
-    NS_ASSERTION(size_forward() > 0,
+    NS_ASSERTION(mEnd - mPosition > 0,
                  "You can't |write| into an |nsWritingIterator| with no space!");
 
     nsCharTraits<value_type>::move(mPosition, aS, aN);
     advance(difference_type(aN));
   }
 
   // We return an unsigned type here (with corresponding assert) rather than
   // the more usual difference_type because we want to make this class go