]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress_common.h
Avoid branch in 'num_bits == 0' branch when peeking bits
[wimlib] / include / wimlib / decompress_common.h
index 420f7f41e3adf8a207248241a41aee0db3ee3879..ce731dca39ba40cc4c3c92c2f5a973a6fd59084a 100644 (file)
@@ -90,9 +90,7 @@ overflow:
 static inline u32
 bitstream_peek_bits(const struct input_bitstream *is, const unsigned num_bits)
 {
-       if (unlikely(num_bits == 0))
-               return 0;
-       return is->bitbuf >> (32 - num_bits);
+       return (is->bitbuf >> 1) >> (sizeof(is->bitbuf) * 8 - num_bits - 1);
 }
 
 /* Remove @num_bits from the bitstream.  There must be at least @num_bits