Skip to content

Commit

Permalink
perf(timeline): dedupe groups around position
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Nov 30, 2021
1 parent 0b4c9b7 commit 51843fb
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,19 @@ export async function fetchLayers () {
}

export function getGroupsAroundPosition (layer: Layer, startPosition: number, endPosition: number): EventGroup[] {
const result: EventGroup[] = []
const result = new Set<EventGroup>()
let key = Math.round(startPosition / 100)
const endKey = Math.round(endPosition / 100)
while (key <= endKey) {
const groups = layer.groupPositionCache[key]
if (groups) {
result.push(...groups)
for (const group of groups) {
result.add(group)
}
}
key++
}
return result
return Array.from(result)
}

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

0 comments on commit 51843fb

Please sign in to comment.