From d8e24314ec120543729bb8bb31b8519731f1f4cf Mon Sep 17 00:00:00 2001 From: skomerko <168652295+skomerko@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:13:45 +0200 Subject: [PATCH] WebUI: Improve lookup performance when filtering by tracker Torrent hashes in tracker list are now kept in sets instead of arrays. PR #21405. --- src/webui/www/private/scripts/client.js | 3 +-- src/webui/www/private/scripts/dynamicTable.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index c48c8542a..5922ed32d 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -805,8 +805,7 @@ window.addEventListener("DOMContentLoaded", () => { trackerListItem = { host: host, trackerTorrentMap: new Map() }; trackerList.set(hash, trackerListItem); } - - trackerListItem.trackerTorrentMap.set(tracker, [...torrents]); + trackerListItem.trackerTorrentMap.set(tracker, new Set(torrents)); } updateTrackers = true; } diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index f969d5823..9ae0a2da0 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -1485,7 +1485,7 @@ window.qBittorrent.DynamicTable ??= (() => { if (tracker) { let found = false; for (const torrents of tracker.trackerTorrentMap.values()) { - if (torrents.includes(row["full_data"].rowId)) { + if (torrents.has(row["full_data"].rowId)) { found = true; break; }