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

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

Issue 75233002: Don't find(':') twice in WebVTTParser::collectMetadataHeader (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 cddec3461f1916dfc75893afe5b7998e3809b204..fffc502f137bdc963b7694afdf2ff873b68919cf 100644
--- a/Source/core/html/track/vtt/VTTParser.cpp
+++ b/Source/core/html/track/vtt/VTTParser.cpp
@@ -244,13 +244,17 @@ void WebVTTParser::collectMetadataHeader(const String& line)
// WebVTT header parsing (WebVTT parser algorithm step 12)
DEFINE_STATIC_LOCAL(const AtomicString, regionHeaderName, ("Region", AtomicString::ConstructFromLiteral));
+ // The only currently supported header is the "Region" header.
+ if (!RuntimeEnabledFeatures::webVTTRegionsEnabled())
+ return;
+
// Step 12.4 If line contains the character ":" (A U+003A COLON), then set metadata's
// name to the substring of line before the first ":" character and
// metadata's value to the substring after this character.
- if (!RuntimeEnabledFeatures::webVTTRegionsEnabled() || !line.contains(":"))
+ unsigned colonPosition = line.find(':');
+ if (colonPosition == kNotFound)
return;
- unsigned colonPosition = line.find(":");
String headerName = line.substring(0, colonPosition);
// Steps 12.5 If metadata's name equals "Region":
« 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