]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress_common.h
xpress-decompress.c: Performance tweaks
[wimlib] / include / wimlib / decompress_common.h
index 3f3742a02ea750aad757febe523109b9441954d6..99930b940f9a09053c5796c8acdc87b35a5478ad 100644 (file)
@@ -131,11 +131,24 @@ bitstream_read_bits(struct input_bitstream *is, unsigned num_bits)
 static inline u8
 bitstream_read_byte(struct input_bitstream *is)
 {
-       if (unlikely(is->end - is->next < 1))
+       if (unlikely(is->end == is->next))
                return 0;
        return *is->next++;
 }
 
+/* Read and return the next 16-bit integer embedded in the bitstream.  */
+static inline u16
+bitstream_read_u16(struct input_bitstream *is)
+{
+       u16 v;
+
+       if (unlikely(is->end - is->next < 2))
+               return 0;
+       v = le16_to_cpu(*(const le16 *)is->next);
+       is->next += 2;
+       return v;
+}
+
 /* Read and return the next 32-bit integer embedded in the bitstream.  */
 static inline u32
 bitstream_read_u32(struct input_bitstream *is)