Bug 1424120 - Part 4: Remove haveValue logic from ToInteger. r=njn
authorEric Rahm <erahm@mozilla.com>
Thu, 07 Dec 2017 18:44:03 -0800
changeset 448696 b24d0d0ff3c81f0c3e7f9b013440a35f6ed20e55
parent 448695 3dfe583bf4c3611512b59ed0b0152f5da7065d6a
child 448697 2423de2699b16ffd269fc463e4e2515c0d26d101
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1424120
milestone59.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 1424120 - Part 4: Remove haveValue logic from ToInteger. r=njn The `haveValue` logic is no longer necessary. If we don't have a value the result will always be 0.
xpcom/string/nsTStringObsolete.cpp
--- a/xpcom/string/nsTStringObsolete.cpp
+++ b/xpcom/string/nsTStringObsolete.cpp
@@ -164,47 +164,42 @@ ToIntegerCommon(const nsTString<T>& aSrc
     if (done) {
       // Step back.
       cp--;
 
       //integer found
       *aErrorCode = NS_OK;
 
       //now iterate the numeric chars and build our result
-      bool haveValue = false;
-
       while(cp<endcp){
         theChar=*cp++;
         if(('0'<=theChar) && (theChar<='9')){
           result = (aRadix * result) + (theChar-'0');
-          haveValue = true;
         }
         else if((theChar>='A') && (theChar<='F')) {
           if(10==aRadix) {
             *aErrorCode=NS_ERROR_ILLEGAL_VALUE;
             result=0;
             break;
           }
           else {
             result = (aRadix * result) + ((theChar-'A')+10);
-            haveValue = true;
           }
         }
         else if((theChar>='a') && (theChar<='f')) {
           if(10==aRadix) {
             *aErrorCode=NS_ERROR_ILLEGAL_VALUE;
             result=0;
             break;
           }
           else {
             result = (aRadix * result) + ((theChar-'a')+10);
-            haveValue = true;
           }
         }
-        else if((('X'==theChar) || ('x'==theChar)) && (!haveValue || result == 0)) {
+        else if((('X'==theChar) || ('x'==theChar)) && result == 0) {
           // For some reason we support a leading 'x' regardless of radix. For
           // example: "000000x500", aRadix = 10 would be parsed as 500 rather
           // than 0.
           continue;
         }
         else {
           //we've encountered a char that's not a legal number or sign
           break;