Browse Source

[2764] use x % 8 instead of x & 7 to check x is a multiple of 8

assuming the compiler optimizes the former (more understandable but
possibly less efficient) to the latter (less understandable but
efficient).
JINMEI Tatuya 12 years ago
parent
commit
b48b9c7e0d
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/lib/util/encode/base_n.cc

+ 1 - 1
src/lib/util/encode/base_n.cc

@@ -378,7 +378,7 @@ BaseNTransformer<BitsPerChunk, BaseZeroCode, Encoder, Decoder>::decode(
         // Number of bits of the conversion result including padding must be
         // Number of bits of the conversion result including padding must be
         // a multiple of 8; otherwise the decoder reaches the end of input
         // a multiple of 8; otherwise the decoder reaches the end of input
         // with some incomplete bits of data, which is invalid.
         // with some incomplete bits of data, which is invalid.
-        if (((char_count * BitsPerChunk) & 7) != 0) {
+        if (((char_count * BitsPerChunk) % 8) != 0) {
             throw IncompleteBaseInput(); // catch this immediately below
             throw IncompleteBaseInput(); // catch this immediately below
         }
         }
     } catch (const IncompleteBaseInput&) {
     } catch (const IncompleteBaseInput&) {