perf(renderer): reduce sidebar signature allocations
This commit is contained in:
parent
d5db717b54
commit
5d129ce822
1 changed files with 20 additions and 19 deletions
|
|
@ -230,37 +230,37 @@ let cachedLeadOfflineTeamsSource: Partial<Record<string, LeadActivityState>> | n
|
||||||
let cachedLeadOfflineTeamsSignature = '';
|
let cachedLeadOfflineTeamsSignature = '';
|
||||||
let cachedLeadOfflineTeamNames: string[] = [];
|
let cachedLeadOfflineTeamNames: string[] = [];
|
||||||
|
|
||||||
function appendSignaturePart(signature: string, part: unknown): string {
|
function pushSignaturePart(parts: string[], part: unknown): void {
|
||||||
const text = part == null ? '' : String(part);
|
const text = part == null ? '' : String(part);
|
||||||
return `${signature}${text.length}:${text}|`;
|
parts.push(`${text.length}:${text}|`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSidebarTeamsSignature(teams: readonly TeamSummary[]): string {
|
function buildSidebarTeamsSignature(teams: readonly TeamSummary[]): string {
|
||||||
let signature = '';
|
const signatureParts: string[] = [];
|
||||||
for (const team of teams) {
|
for (const team of teams) {
|
||||||
signature = appendSignaturePart(signature, team.teamName);
|
pushSignaturePart(signatureParts, team.teamName);
|
||||||
signature = appendSignaturePart(signature, team.displayName);
|
pushSignaturePart(signatureParts, team.displayName);
|
||||||
signature = appendSignaturePart(signature, team.projectPath);
|
pushSignaturePart(signatureParts, team.projectPath);
|
||||||
signature = appendSignaturePart(signature, team.lastActivity);
|
pushSignaturePart(signatureParts, team.lastActivity);
|
||||||
signature = appendSignaturePart(signature, team.partialLaunchFailure ? 1 : 0);
|
pushSignaturePart(signatureParts, team.partialLaunchFailure ? 1 : 0);
|
||||||
signature = appendSignaturePart(signature, team.teamLaunchState);
|
pushSignaturePart(signatureParts, team.teamLaunchState);
|
||||||
for (const member of team.members ?? []) {
|
for (const member of team.members ?? []) {
|
||||||
const colorMember = member as TeamMemberColorInput;
|
const colorMember = member as TeamMemberColorInput;
|
||||||
signature = appendSignaturePart(signature, colorMember.name);
|
pushSignaturePart(signatureParts, colorMember.name);
|
||||||
signature = appendSignaturePart(signature, colorMember.color);
|
pushSignaturePart(signatureParts, colorMember.color);
|
||||||
signature = appendSignaturePart(signature, colorMember.agentType);
|
pushSignaturePart(signatureParts, colorMember.agentType);
|
||||||
signature = appendSignaturePart(signature, colorMember.removedAt);
|
pushSignaturePart(signatureParts, colorMember.removedAt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return signature;
|
return signatureParts.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTeamNamesIdentityKey(teams: readonly TeamSummary[]): string {
|
function buildTeamNamesIdentityKey(teams: readonly TeamSummary[]): string {
|
||||||
let signature = '';
|
const signatureParts: string[] = [];
|
||||||
for (const team of teams) {
|
for (const team of teams) {
|
||||||
signature = appendSignaturePart(signature, team.teamName);
|
pushSignaturePart(signatureParts, team.teamName);
|
||||||
}
|
}
|
||||||
return signature;
|
return signatureParts.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLeadOfflineTeamNames(
|
function selectLeadOfflineTeamNames(
|
||||||
|
|
@ -278,10 +278,11 @@ function selectLeadOfflineTeamNames(
|
||||||
}
|
}
|
||||||
offlineTeamNames.sort();
|
offlineTeamNames.sort();
|
||||||
|
|
||||||
let signature = '';
|
const signatureParts: string[] = [];
|
||||||
for (const teamName of offlineTeamNames) {
|
for (const teamName of offlineTeamNames) {
|
||||||
signature = appendSignaturePart(signature, teamName);
|
pushSignaturePart(signatureParts, teamName);
|
||||||
}
|
}
|
||||||
|
const signature = signatureParts.join('');
|
||||||
|
|
||||||
if (signature === cachedLeadOfflineTeamsSignature) {
|
if (signature === cachedLeadOfflineTeamsSignature) {
|
||||||
cachedLeadOfflineTeamsSource = leadActivityByTeam;
|
cachedLeadOfflineTeamsSource = leadActivityByTeam;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue