diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-12 19:57:24 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-12 19:57:24 +0000 |
| commit | 8ccaff0d8eaffe5548db0d71ffa804c036641194 (patch) | |
| tree | 3887d129c684ac76274dba1ea384a112c9792c64 /util | |
| parent | 9f41591a46c8879bd99e8706f9ac0fdd0ad1f694 (diff) | |
util/spkmodem-recv: also cache sep_pos in decode
yet another optimisation for weaker compilers - but
some modern compilers may not optimise well for this
code either.
this reduces the amount of references to the struct,
which is very expensive (48000 times per second) on
very old CPUs.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
| -rw-r--r-- | util/spkmodem_recv/spkmodem-recv.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index d1e39aad..eaf80717 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -180,12 +180,14 @@ decode_pulse(struct decoder_state *st) unsigned char old_ring, old_sep; unsigned char new_pulse; int ringpos; + int sep_pos; signed short sample; ringpos = st->ringpos; + sep_pos = st->sep_pos; old_ring = st->pulse[ringpos]; - old_sep = st->pulse[st->sep_pos]; + old_sep = st->pulse[sep_pos]; st->freq_data -= old_ring; st->freq_data += old_sep; @@ -206,11 +208,12 @@ decode_pulse(struct decoder_state *st) if (ringpos >= MAX_SAMPLES) ringpos = 0; - st->ringpos = ringpos; + sep_pos++; + if (sep_pos >= MAX_SAMPLES) + sep_pos = 0; - st->sep_pos++; - if (st->sep_pos >= MAX_SAMPLES) - st->sep_pos = 0; + st->ringpos = ringpos; + st->sep_pos = sep_pos; st->sample_count++; } |
