From a296f2783fb3e2afbd0b411d9119d94f55839da5 Mon Sep 17 00:00:00 2001 From: Malcolm Robb Date: Tue, 30 Apr 2013 10:46:23 +0100 Subject: [PATCH] Make stats gathering conditional on Modes.stats There is a quite complex if/else construct for gathering statistics inside the main decodeModeS loop. To speed the loop up when not gathering statistics, make the whole construct conditional on Modes.stat being set. Also tidy up a few comments --- dump1090.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/dump1090.c b/dump1090.c index 2b5b52a..d2d5808 100644 --- a/dump1090.c +++ b/dump1090.c @@ -2021,25 +2021,25 @@ void detectModeS(uint16_t *m, uint32_t mlen) { // Decode the received message decodeModesMessage(&mm, msg); - /* Update statistics. */ - if (mm.crcok || use_correction) { - if (errors == 0) Modes.stat_demodulated++; - if (mm.errorbit == -1) { - if (mm.crcok) - Modes.stat_goodcrc++; - else + // Update statistics + if (Modes.stats) { + if (mm.crcok || use_correction) { + if (errors == 0) Modes.stat_demodulated++; + if (mm.errorbit == -1) { + if (mm.crcok) {Modes.stat_goodcrc++;} + else {Modes.stat_badcrc++;} + } else { Modes.stat_badcrc++; - } else { - Modes.stat_badcrc++; - Modes.stat_fixed++; - if (mm.errorbit < MODES_LONG_MSG_BITS) - Modes.stat_single_bit_fix++; - else - Modes.stat_two_bits_fix++; + Modes.stat_fixed++; + if (mm.errorbit < MODES_LONG_MSG_BITS) + {Modes.stat_single_bit_fix++;} + else + {Modes.stat_two_bits_fix++;} + } } } - /* Output debug mode info if needed. */ + // Output debug mode info if needed if (use_correction) { if (Modes.debug & MODES_DEBUG_DEMOD) dumpRawMessage("Demodulated with 0 errors", msg, m, j); @@ -2052,7 +2052,7 @@ void detectModeS(uint16_t *m, uint32_t mlen) { dumpRawMessage("Decoded with good CRC", msg, m, j); } - /* Skip this message if we are sure it's fine. */ + // Skip this message if we are sure it's fine if (mm.crcok) { j += (MODES_PREAMBLE_US+msglen)*2; good_message = 1; @@ -2060,7 +2060,7 @@ void detectModeS(uint16_t *m, uint32_t mlen) { mm.phase_corrected = 1; } - /* Pass data to the next layer */ + // Pass data to the next layer useModesMessage(&mm); } else {