зеркало из https://github.com/mozilla/gecko-dev.git
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. --HG-- extra : rebase_source : df79cbe1dab86914873de72f0ef8fe72d3469e1a
This commit is contained in:
Родитель
8601b5e802
Коммит
b1ed165c5e
|
@ -169,13 +169,10 @@ ToIntegerCommon(const nsTString<T>& aSrc,
|
|||
*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) {
|
||||
|
@ -185,7 +182,6 @@ ToIntegerCommon(const nsTString<T>& aSrc,
|
|||
}
|
||||
else {
|
||||
result = (aRadix * result) + ((theChar-'A')+10);
|
||||
haveValue = true;
|
||||
}
|
||||
}
|
||||
else if((theChar>='a') && (theChar<='f')) {
|
||||
|
@ -196,10 +192,9 @@ ToIntegerCommon(const nsTString<T>& aSrc,
|
|||
}
|
||||
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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче