Skip to content

Commit d9bc1f0

Browse files
committed
linkedin#52: first phase of imporvement, skipped three iteration of the rFA
1 parent 498efb3 commit d9bc1f0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/metal/engine.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class Engine implements EngineInterface {
1616
private reads: Array<Function> = [];
1717
private work: Array<Function> = [];
1818
private running: Boolean = false;
19+
private skipCounter: number = 4;
1920
scheduleRead(callback: Function) {
2021
this.reads.unshift(callback);
2122
this.run();
@@ -28,14 +29,18 @@ export class Engine implements EngineInterface {
2829
if (!this.running) {
2930
this.running = true;
3031
W.rAF(() => {
31-
this.running = false;
32-
for (let i = 0, rlen = this.reads.length; i < rlen; i++) {
33-
this.reads.pop()();
34-
}
35-
for (let i = 0, wlen = this.work.length; i < wlen; i++) {
36-
this.work.pop()();
32+
if (this.skipCounter > 3) {
33+
this.skipCounter = 0;
34+
for (let i = 0, rlen = this.reads.length; i < rlen; i++) {
35+
this.reads.pop()();
36+
}
37+
for (let i = 0, wlen = this.work.length; i < wlen; i++) {
38+
this.work.pop()();
39+
}
3740
}
41+
this.skipCounter++;
3842
if (this.work.length > 0 || this.reads.length > 0) {
43+
this.running = false;
3944
this.run();
4045
}
4146
});

0 commit comments

Comments
 (0)