Performance use static variable max_nbits in macro
@@ -118,7 +118,7 @@ char* grib_decode_string(const unsigned char* bitStream, long *bitOffset, size_t
/* A mask with x least-significant bits set, possibly 0 or >=32 */
/* -1UL is 1111111... in every bit in binary representation */
#define BIT_MASK(x) \
- (((x) >= sizeof(unsigned long) * 8) ? \
+ (((x) >= max_nbits) ? \
(unsigned long) -1UL : (1UL << (x)) - 1)
/**
* decode a value consisting of nbits from an octet-bitstream to long-representation
