aboutsummaryrefslogtreecommitdiff
path: root/src/peripherals
diff options
context:
space:
mode:
authorUri Shaked2020-05-25 16:23:07 +0300
committerUri Shaked2020-05-25 16:23:07 +0300
commit22f6bd46d2f355d8974feba54223fe884fcd8e29 (patch)
tree68288e56637ea49f5389f1c5a1ee245182d32065 /src/peripherals
parentfeat(timer): Compare Match Output (#45) (diff)
downloadavr8js-22f6bd46d2f355d8974feba54223fe884fcd8e29.tar.gz
avr8js-22f6bd46d2f355d8974feba54223fe884fcd8e29.tar.bz2
avr8js-22f6bd46d2f355d8974feba54223fe884fcd8e29.zip
perf(timer): improve tick() performance
reduce the number of calls to TIFR/TIMSK getters
Diffstat (limited to '')
-rw-r--r--src/peripherals/timer.ts7
1 files changed, 4 insertions, 3 deletions
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;
}