From c52fc6f9d306530cec46c7137c6e450b9316356a Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Fri, 12 Jun 2026 16:09:35 +0200 Subject: [PATCH] perf: constant-time match lookups in standings model Co-Authored-By: Claude Fable 5 --- lua/wikis/commons/Standings.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/wikis/commons/Standings.lua b/lua/wikis/commons/Standings.lua index da891d1d3cb..079b00ba297 100644 --- a/lua/wikis/commons/Standings.lua +++ b/lua/wikis/commons/Standings.lua @@ -175,9 +175,10 @@ function Standings.fetchMatches(standings) return MatchGroupUtil.splitMatchId(matchid) end)) + local wantedMatchIds = Table.map(matchids, function(_, matchid) return matchid, true end) local allMatchesFromBrackets = Array.flatMap(bracketIds, MatchGroupUtil.fetchMatches) return Array.filter(allMatchesFromBrackets, function(match) - return Table.includes(matchids, match.matchId) + return wantedMatchIds[match.matchId] end) end @@ -193,10 +194,7 @@ function Standings.fetchMatch(entry) return end - local allMatchesFromBrackets = MatchGroupUtil.fetchMatches(bracketId) - return Array.filter(allMatchesFromBrackets, function(match) - return match.matchId == matchid - end)[1] + return MatchGroupUtil.fetchMatchGroup(bracketId).matchesById[matchid] end ---@param standings StandingsModel