From 972fb2e16750849d749be197bcd6f7142eda456f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 12 Dec 2017 22:08:55 +0100 Subject: [PATCH] chg: micro opt.. --- client/cmdhfmfhard.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/client/cmdhfmfhard.c b/client/cmdhfmfhard.c index 6f19e778e..ac19f911c 100644 --- a/client/cmdhfmfhard.c +++ b/client/cmdhfmfhard.c @@ -1697,16 +1697,12 @@ static inline bool bitflips_match(uint8_t byte, uint32_t state, odd_even_t odd_e } -static uint_fast8_t reverse(uint_fast8_t byte) +static uint_fast8_t reverse(uint_fast8_t b) { - uint_fast8_t rev_byte = 0; - - for (uint8_t i = 0; i < 8; i++) { - rev_byte <<= 1; - rev_byte |= (byte >> i) & 0x01; - } - - return rev_byte; + b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; + b = (b & 0xCC) >> 2 | (b & 0x33) << 2; + b = (b & 0xAA) >> 1 | (b & 0x55) << 1; + return b; }