Skip to content

Commit 51843fb

Browse files
committed
perf(timeline): dedupe groups around position
1 parent 0b4c9b7 commit 51843fb

File tree

1 file changed

+5
-3
lines changed
  • packages/app-frontend/src/features/timeline/composable

1 file changed

+5
-3
lines changed

packages/app-frontend/src/features/timeline/composable/layers.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,19 @@ export async function fetchLayers () {
129129
}
130130

131131
export function getGroupsAroundPosition (layer: Layer, startPosition: number, endPosition: number): EventGroup[] {
132-
const result: EventGroup[] = []
132+
const result = new Set<EventGroup>()
133133
let key = Math.round(startPosition / 100)
134134
const endKey = Math.round(endPosition / 100)
135135
while (key <= endKey) {
136136
const groups = layer.groupPositionCache[key]
137137
if (groups) {
138-
result.push(...groups)
138+
for (const group of groups) {
139+
result.add(group)
140+
}
139141
}
140142
key++
141143
}
142-
return result
144+
return Array.from(result)
143145
}
144146

145147
export function addGroupAroundPosition (layer: Layer, group: EventGroup, newPosition: number) {

0 commit comments

Comments
 (0)