From b549b6036c4baa2b987f4c0276cc2b0edf623dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 8 Jun 2023 20:29:16 +0200 Subject: [PATCH] fix(HLS): Avoid variable substitution if no variables (#5269) With this change, we improve performance on very large playlists. --- lib/hls/hls_parser.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index f27aed2b0e..1c5c1384e9 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2451,6 +2451,9 @@ shaka.hls.HlsParser = class { * @private */ variableSubstitution_(uri, variables) { + if (!variables.size) { + return uri; + } let newUri = String(uri).replace(/%7B/g, '{').replace(/%7D/g, '}'); const uriVariables = newUri.match(/{\$\w*}/g);