From 9802f65dd9fa8056d969bc228e5cfdeac2458843 Mon Sep 17 00:00:00 2001 From: Ivan <48260572+vanyaxk@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:39:09 +0100 Subject: [PATCH] perf(HLS): do not filter all tags to get the first tag (#6088) Filtering all the tags to get the first one that's required is not needed Co-authored-by: Ivan Kohut --- lib/hls/hls_utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/hls/hls_utils.js b/lib/hls/hls_utils.js index 4414540904..4ecc9e599f 100644 --- a/lib/hls/hls_utils.js +++ b/lib/hls/hls_utils.js @@ -47,12 +47,12 @@ shaka.hls.Utils = class { * @return {?shaka.hls.Tag} */ static getFirstTagWithName(tags, name) { - const tagsWithName = shaka.hls.Utils.filterTagsByName(tags, name); - if (!tagsWithName.length) { - return null; + for (const tag of tags) { + if (tag.name === name) { + return tag; + } } - - return tagsWithName[0]; + return null; } /**