From 22f6bd46d2f355d8974feba54223fe884fcd8e29 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Mon, 25 May 2020 16:23:07 +0300 Subject: perf(timer): improve tick() performance reduce the number of calls to TIFR/TIMSK getters --- src/peripherals/timer.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/peripherals/timer.ts b/src/peripherals/timer.ts index 4293a49..c6bf742 100644 --- a/src/peripherals/timer.ts +++ b/src/peripherals/timer.ts @@ -363,15 +363,16 @@ export class AVRTimer { } this.tcntUpdated = false; if (this.cpu.interruptsEnabled) { - if (this.TIFR & TOV && this.TIMSK & TOIE) { + const { TIFR, TIMSK } = this; + if (TIFR & TOV && TIMSK & TOIE) { avrInterrupt(this.cpu, this.config.ovfInterrupt); this.TIFR &= ~TOV; } - if (this.TIFR & OCFA && this.TIMSK & OCIEA) { + if (TIFR & OCFA && TIMSK & OCIEA) { avrInterrupt(this.cpu, this.config.compAInterrupt); this.TIFR &= ~OCFA; } - if (this.TIFR & OCFB && this.TIMSK & OCIEB) { + if (TIFR & OCFB && TIMSK & OCIEB) { avrInterrupt(this.cpu, this.config.compBInterrupt); this.TIFR &= ~OCFB; } -- cgit v1.2.3