Skip to content

Commit 0b4c9b7

Browse files
committed
perf(timeline): remove getTimePosition cache
1 parent 993a5b2 commit 0b4c9b7

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

packages/app-frontend/src/features/timeline/TimelineView.vue

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,12 @@ export default defineComponent({
102102
microTasks.push([task, priority])
103103
}
104104
105-
// Get pixel position for giver time
106-
107-
let timePositionCache: Record<number, number> = {}
105+
/**
106+
* Get pixel position for giver time
107+
*/
108108
function getTimePosition (time: number) {
109-
let result = timePositionCache[time]
110-
if (result == null) {
111-
result = (time - nonReactiveState.minTime.value) / (nonReactiveState.endTime.value - nonReactiveState.startTime.value) * app.view.width / window.devicePixelRatio
112-
timePositionCache[time] = result
113-
}
114-
return result
115-
}
116-
function resetTimePositionCache () {
117-
timePositionCache = {}
109+
return (time - nonReactiveState.minTime.value) / (nonReactiveState.endTime.value - nonReactiveState.startTime.value) * app.view.width / window.devicePixelRatio
118110
}
119-
watch(minTime, resetTimePositionCache)
120-
watch(endTime, resetTimePositionCache)
121-
watch(startTime, resetTimePositionCache)
122111
123112
// Reset
124113
@@ -1329,7 +1318,6 @@ export default defineComponent({
13291318
app.queueResize()
13301319
nextTick(() => {
13311320
mainRenderTexture?.resize(app.view.width, app.view.height)
1332-
resetTimePositionCache()
13331321
queueEventsUpdate()
13341322
drawLayerBackgroundEffects()
13351323
drawTimeCursor()

0 commit comments

Comments
 (0)