Only render fg cells if there are changes

This commit is contained in:
Daniel Imms
2017-08-30 22:55:17 -07:00
parent d93a80398d
commit 6a0b9bd209
4 changed files with 53 additions and 28 deletions
+20
View File
@@ -0,0 +1,20 @@
export class GridCache<T> {
public cache: T[][];
public constructor() {
this.cache = [];
}
public resize(width: number, height: number) {
for (let x = 0; x < width; x++) {
if (this.cache.length <= x) {
this.cache.push([]);
}
for (let y = this.cache[x].length; y < height; y++) {
this.cache[x].push(null);
}
this.cache[x].length = height;
}
this.cache.length = width;
}
}