Cache the output of SpeedProvider.getRanges during a drag to increase speed provider performance

This commit is contained in:
Manuel Vögele
2021-04-29 12:40:17 +02:00
parent 4671e6de51
commit 1acc012d65
3 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -1,6 +1,9 @@
## In development
### Bugfixes
### Performance
- Greatly increased the performance when playing on huge maps and when moving many tokens at once.
- Huge performance improvements for speed providers. (Technical details: `getRanges` is now being called way less frequently)
### Bugfixes
- When starting to drag a new token while the previous one is still moving the ruler won't dissappear anymore when the previous token arrives at it's destination.
+3 -1
View File
@@ -185,7 +185,9 @@ export function getColorForDistance(startDistance, subDistance=0) {
return this.color
}
const distance = startDistance + subDistance
const ranges = getRangesFromSpeedProvider(this.draggedToken)
if (!this.dragRulerRanges)
this.dragRulerRanges = getRangesFromSpeedProvider(this.draggedToken)
const ranges = this.dragRulerRanges;
if (ranges.length === 0)
return this.color
const currentRange = ranges.reduce((minRange, currentRange) => {
+1
View File
@@ -14,6 +14,7 @@ export class DragRulerRuler extends Ruler {
super.clear();
this.previousWaypoints = [];
this.previousLabels.removeChildren().forEach(c => c.destroy());
this.dragRulerRanges = undefined;
}
async moveToken(event) {