From 141330a18f7d58702fb474f00ba18f00f930e77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Wed, 10 Jan 2024 09:14:54 +0100 Subject: [PATCH] perf(VTT): Improve parsing time for unstyled payloads --- lib/text/vtt_text_parser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/text/vtt_text_parser.js b/lib/text/vtt_text_parser.js index 8590d58158..54379b8018 100644 --- a/lib/text/vtt_text_parser.js +++ b/lib/text/vtt_text_parser.js @@ -451,6 +451,11 @@ shaka.text.VttTextParser = class { */ static parseCueStyles(payload, rootCue, styles) { const VttTextParser = shaka.text.VttTextParser; + // Optimization for unstyled payloads. + if (!payload.includes('<')) { + rootCue.payload = VttTextParser.htmlUnescape_(payload); + return; + } if (styles.size === 0) { VttTextParser.addDefaultTextColor_(styles); }