Skip to content

Commit 5720716

Browse files
committed
refactor(view): 배열 업데이트 성능 최적화
groupCommitsByReleaseTags 함수에서 불변성을 유지하면서 배열 업데이트 성능을 개선했습니다. - slice(0, -1)과 spread operator 중복 사용 제거 - 배열 복사를 1회로 줄여 성능 향상 - 불변성은 slice()를 통해 유지
1 parent 91859bf commit 5720716

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

packages/view/src/components/FolderActivityFlow/FolderActivityFlow.releaseAnalyzer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function groupCommitsByReleaseTags(clusterNodeList: ClusterNode[]): Relea
9595

9696
// For commits without release tags
9797
if (acc.lastGroup) {
98-
// Add to existing group (maintaining immutability)
98+
// Add to existing group (maintaining immutability with optimized array copy)
9999
const updatedLastGroup: ReleaseGroup = {
100100
...acc.lastGroup,
101101
commits: [...acc.lastGroup.commits, commit],
@@ -106,8 +106,12 @@ export function groupCommitsByReleaseTags(clusterNodeList: ClusterNode[]): Relea
106106
},
107107
};
108108

109+
// Optimized: shallow copy array and replace last element
110+
const updatedGroups = acc.groups.slice();
111+
updatedGroups[updatedGroups.length - 1] = updatedLastGroup;
112+
109113
return {
110-
groups: [...acc.groups.slice(0, -1), updatedLastGroup],
114+
groups: updatedGroups,
111115
lastGroup: updatedLastGroup,
112116
};
113117
}

packages/view/src/components/FolderActivityFlow/FolderActivityFlow.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ export interface ReleaseFlowLineData {
3535
endReleaseIndex: number;
3636
endFolder: string;
3737
contributorName: string;
38-
}
38+
}

0 commit comments

Comments
 (0)