Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Unified Diff: third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp

Issue 1582813003: Remove redundant emptiness check from genericParseNumber (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-use/name ptrStartIntPart. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp b/third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp
index f1af2cb4321e092b42b380458087a50be2a7f407..d098d3f09a1b49a97e83f4dcf1e7183259be5ad6 100644
--- a/third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp
@@ -42,7 +42,6 @@ static bool genericParseNumber(const CharType*& ptr, const CharType* end, FloatT
{
FloatType integer, decimal, frac, exponent;
int sign, expsign;
- const CharType* start = ptr;
exponent = 0;
integer = 0;
@@ -67,14 +66,14 @@ static bool genericParseNumber(const CharType*& ptr, const CharType* end, FloatT
return false;
// read the integer part, build right-to-left
- const CharType* ptrStartIntPart = ptr;
+ const CharType* digitsStart = ptr;
while (ptr < end && *ptr >= '0' && *ptr <= '9')
++ptr; // Advance to first non-digit.
- if (ptr != ptrStartIntPart) {
+ if (ptr != digitsStart) {
const CharType* ptrScanIntPart = ptr - 1;
FloatType multiplier = 1;
- while (ptrScanIntPart >= ptrStartIntPart) {
+ while (ptrScanIntPart >= digitsStart) {
integer += multiplier * static_cast<FloatType>(*(ptrScanIntPart--) - '0');
multiplier *= 10;
}
@@ -94,8 +93,12 @@ static bool genericParseNumber(const CharType*& ptr, const CharType* end, FloatT
decimal += (*(ptr++) - '0') * (frac *= static_cast<FloatType>(0.1));
}
+ // When we get here we should have consumed either a digit for the integer
+ // part or a fractional part (with at least one digit after the '.'.)
+ ASSERT(digitsStart != ptr);
+
// read the exponent part
- if (ptr != start && ptr + 1 < end && (*ptr == 'e' || *ptr == 'E')
+ if (ptr + 1 < end && (*ptr == 'e' || *ptr == 'E')
&& (ptr[1] != 'x' && ptr[1] != 'm')) {
ptr++;
@@ -131,9 +134,6 @@ static bool genericParseNumber(const CharType*& ptr, const CharType* end, FloatT
if (!isValidRange(number))
return false;
- if (start == ptr)
- return false;
-
if (mode & AllowTrailingWhitespace)
skipOptionalSVGSpacesOrDelimiter(ptr, end);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698