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

Unified Diff: Source/core/html/track/vtt/VTTParser.cpp

Issue 104443002: Simplify VTTParser::collectTimeStamp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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: Source/core/html/track/vtt/VTTParser.cpp
diff --git a/Source/core/html/track/vtt/VTTParser.cpp b/Source/core/html/track/vtt/VTTParser.cpp
index f6b0e52e41fc2506236f6a4372952f1f9b2efccc..dcbce8b682792b4bfcab33e4e642e9a7a550a0e5 100644
--- a/Source/core/html/track/vtt/VTTParser.cpp
+++ b/Source/core/html/track/vtt/VTTParser.cpp
@@ -468,20 +468,19 @@ double VTTParser::collectTimeStamp(const String& line, unsigned* position)
// Steps 1 - 4 - Initial checks, let most significant units be minutes.
enum Mode { Minutes, Hours };
Mode mode = Minutes;
- if (*position >= line.length() || !isASCIIDigit(line[*position]))
- return malformedTime;
- int value1;
// Steps 5 - 7 - Collect a sequence of characters that are 0-9.
// If not 2 characters or value is greater than 59, interpret as hours.
- if (collectDigitsToInt(line, position, value1) != 2 || value1 > 59)
+ int value1;
+ unsigned value1Digits = collectDigitsToInt(line, position, value1);
+ if (!value1Digits)
+ return malformedTime;
+ if (value1Digits != 2 || value1 > 59)
mode = Hours;
// Steps 8 - 11 - Collect the next sequence of 0-9 after ':' (must be 2 chars).
if (*position >= line.length() || line[(*position)++] != ':')
return malformedTime;
- if (*position >= line.length() || !isASCIIDigit(line[(*position)]))
- return malformedTime;
int value2;
if (collectDigitsToInt(line, position, value2) != 2)
return malformedTime;
@@ -491,8 +490,6 @@ double VTTParser::collectTimeStamp(const String& line, unsigned* position)
if (mode == Hours || (*position < line.length() && line[*position] == ':')) {
if (*position >= line.length() || line[(*position)++] != ':')
return malformedTime;
- if (*position >= line.length() || !isASCIIDigit(line[*position]))
- return malformedTime;
if (collectDigitsToInt(line, position, value3) != 2)
return malformedTime;
} else {
@@ -504,8 +501,6 @@ double VTTParser::collectTimeStamp(const String& line, unsigned* position)
// Steps 13 - 17 - Collect next sequence of 0-9 after '.' (must be 3 chars).
if (*position >= line.length() || line[(*position)++] != '.')
return malformedTime;
- if (*position >= line.length() || !isASCIIDigit(line[*position]))
- return malformedTime;
int value4;
if (collectDigitsToInt(line, position, value4) != 3)
return malformedTime;
« 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