Skip to content

Commit 22f6bd4

Browse files
committed
perf(timer): improve tick() performance
reduce the number of calls to TIFR/TIMSK getters
1 parent 00cea56 commit 22f6bd4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/peripherals/timer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,16 @@ export class AVRTimer {
363363
}
364364
this.tcntUpdated = false;
365365
if (this.cpu.interruptsEnabled) {
366-
if (this.TIFR & TOV && this.TIMSK & TOIE) {
366+
const { TIFR, TIMSK } = this;
367+
if (TIFR & TOV && TIMSK & TOIE) {
367368
avrInterrupt(this.cpu, this.config.ovfInterrupt);
368369
this.TIFR &= ~TOV;
369370
}
370-
if (this.TIFR & OCFA && this.TIMSK & OCIEA) {
371+
if (TIFR & OCFA && TIMSK & OCIEA) {
371372
avrInterrupt(this.cpu, this.config.compAInterrupt);
372373
this.TIFR &= ~OCFA;
373374
}
374-
if (this.TIFR & OCFB && this.TIMSK & OCIEB) {
375+
if (TIFR & OCFB && TIMSK & OCIEB) {
375376
avrInterrupt(this.cpu, this.config.compBInterrupt);
376377
this.TIFR &= ~OCFB;
377378
}

0 commit comments

Comments
 (0)