perf(renderer): cache active teammate roster keys
This commit is contained in:
parent
66ab83a7ce
commit
34c2215c31
1 changed files with 12 additions and 2 deletions
|
|
@ -45,10 +45,12 @@ const resolvedMemberSelectorCache = new Map<
|
|||
result: ResolvedTeamMember | null;
|
||||
}
|
||||
>();
|
||||
let activeRawTeammateNameKeysCache = new WeakMap<TeamViewSnapshot['members'], readonly string[]>();
|
||||
|
||||
export function clearResolvedMemberSelectorCaches(): void {
|
||||
resolvedMembersSelectorCache.clear();
|
||||
resolvedMemberSelectorCache.clear();
|
||||
activeRawTeammateNameKeysCache = new WeakMap<TeamViewSnapshot['members'], readonly string[]>();
|
||||
}
|
||||
|
||||
export function clearResolvedMemberSelectorCachesForTeam(teamName: string): void {
|
||||
|
|
@ -162,10 +164,16 @@ function buildConfigFallbackMemberSnapshots(snapshot: TeamViewSnapshot): TeamMem
|
|||
return fallbackMembers;
|
||||
}
|
||||
|
||||
function getActiveRawTeammateNameKeys(snapshot: TeamViewSnapshot | null | undefined): string[] {
|
||||
function getActiveRawTeammateNameKeys(
|
||||
snapshot: TeamViewSnapshot | null | undefined
|
||||
): readonly string[] {
|
||||
if (!snapshot) {
|
||||
return [];
|
||||
}
|
||||
const cached = activeRawTeammateNameKeysCache.get(snapshot.members);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
const names = new Set<string>();
|
||||
for (const member of snapshot.members) {
|
||||
const name = member.name.trim();
|
||||
|
|
@ -175,7 +183,9 @@ function getActiveRawTeammateNameKeys(snapshot: TeamViewSnapshot | null | undefi
|
|||
}
|
||||
names.add(key);
|
||||
}
|
||||
return Array.from(names).sort((left, right) => left.localeCompare(right));
|
||||
const result = Array.from(names).sort((left, right) => left.localeCompare(right));
|
||||
activeRawTeammateNameKeysCache.set(snapshot.members, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
function hasActiveRawTeammateRoster(snapshot: TeamViewSnapshot | null | undefined): boolean {
|
||||
|
|
|
|||
Loading…
Reference in a new issue