From 62a496ec9e02553ce3c662e1d019e4e7655d1fa1 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 12 Mar 2026 04:55:18 +0000 Subject: util/spkmodem-recv: tidy up pulse decoding make it clearer about next/old, in the loop. this also improves performance on older systems (cache the values first, don't re-calculate) again, this is GNU code. but you wouldn't know it, in my current version. i forked this from GRUB several years ago and started cleaning it for fun. Signed-off-by: Leah Rowe --- util/spkmodem_recv/spkmodem-recv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'util/spkmodem_recv/spkmodem-recv.c') diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index 58f59294..bbf73384 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -152,10 +152,14 @@ static void decode_pulse(struct decoder_state *st) { size_t n; + unsigned char old_ring, old_sep; - st->freq_data -= st->pulse[st->ringpos]; - st->freq_data += st->pulse[st->sep_pos]; - st->freq_separator -= st->pulse[st->sep_pos]; + old_ring = st->pulse[st->ringpos]; + old_sep = st->pulse[st->sep_pos]; + + st->freq_data -= old_ring; + st->freq_data += old_sep; + st->freq_separator -= old_sep; n = fread(&st->frame[st->ringpos], sizeof(st->frame[0]), 1, stdin); if (n != 1) { -- cgit v1.2.1