Bug 1305422 - part 8 - make nsSMILParserUtils::CheckForNegativeNumber more idiomatic; r=dholbert
authorNathan Froyd <froydnj@mozilla.com>
Thu, 29 Sep 2016 22:33:57 -0400
changeset 315879 8c6e2e1c4f2a897c153fd6be9a2a6cb52ba2d8d6
parent 315878 caad2bb558f675154302f348a11bd23486c3a16d
child 315880 55be43ac96c9037c2245b3cf0b90f59b38364984
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)
reviewersdholbert
bugs1305422
milestone52.0a1
Bug 1305422 - part 8 - make nsSMILParserUtils::CheckForNegativeNumber more idiomatic; r=dholbert The surrounding code in this file and elsewhere uses pairs of RangedPtrs for iterators. While we're trying to modify nsString's iterators so they're more like RangedPtr, it seems reasonable to go ahead and modify this instance of nsString iterators to use RangedPtr directly for conformity with the surrounding code.
dom/smil/nsSMILParserUtils.cpp
--- a/dom/smil/nsSMILParserUtils.cpp
+++ b/dom/smil/nsSMILParserUtils.cpp
@@ -704,27 +704,27 @@ nsSMILParserUtils::ParseClockValue(const
   return ::ParseClockValue(iter, end, aResult) && iter == end;
 }
 
 int32_t
 nsSMILParserUtils::CheckForNegativeNumber(const nsAString& aStr)
 {
   int32_t absValLocation = -1;
 
-  nsAString::const_iterator start, end;
-  aStr.BeginReading(start);
-  aStr.EndReading(end);
+  RangedPtr<const char16_t> start(SVGContentUtils::GetStartRangedPtr(aStr));
+  RangedPtr<const char16_t> iter = start;
+  RangedPtr<const char16_t> end(SVGContentUtils::GetEndRangedPtr(aStr));
 
   // Skip initial whitespace
-  while (start != end && IsSVGWhitespace(*start)) {
-    ++start;
+  while (iter != end && IsSVGWhitespace(*iter)) {
+    ++iter;
   }
 
   // Check for dash
-  if (start != end && *start == '-') {
-    ++start;
+  if (iter != end && *iter == '-') {
+    ++iter;
     // Check for numeric character
-    if (start != end && SVGContentUtils::IsDigit(*start)) {
-      absValLocation = start.get() - start.start();
+    if (iter != end && SVGContentUtils::IsDigit(*iter)) {
+      absValLocation = iter - start;
     }
   }
   return absValLocation;
 }