]> git.sesse.net Git - fjl/blobdiff - input.h
Upper-case constants.
[fjl] / input.h
diff --git a/input.h b/input.h
index 34765c25b113b35efff8c77ccf4d3f3e09ae30f0..aa4c337ca8304c6b40ba13367b00ccfd8c6b0ea7 100644 (file)
--- a/input.h
+++ b/input.h
@@ -17,9 +17,9 @@ static inline bitreservoir_fill_t read_bitreservoir_fill(uint8_t* source)
        return ntohl(*(bitreservoir_fill_t*)(source));
 }
 
        return ntohl(*(bitreservoir_fill_t*)(source));
 }
 
-static const unsigned bitreservoir_size = 8 * sizeof(bitreservoir_t);
-static const unsigned bitreservoir_fill_size = 8 * sizeof(bitreservoir_fill_t);
-static const unsigned bytereservoir_size = 4096;
+static const unsigned BITRESERVOIR_SIZE = 8 * sizeof(bitreservoir_t);
+static const unsigned BITRESERVOIR_FILL_SIZE = 8 * sizeof(bitreservoir_fill_t);
+static const unsigned BYTERESERVOIR_SIZE = 4096;
 
 // A function to read bytes from some input source. The bytes should be
 // already unstuffed (and thus without markers).
 
 // A function to read bytes from some input source. The bytes should be
 // already unstuffed (and thus without markers).
@@ -55,7 +55,7 @@ void possibly_refill_slow_path(struct bit_source* source, unsigned num_bits);
 // refill A+B, read A, read B than refill A, read A, refill B, read B.
 static inline void possibly_refill(struct bit_source* source, unsigned num_bits)
 {
 // refill A+B, read A, read B than refill A, read A, refill B, read B.
 static inline void possibly_refill(struct bit_source* source, unsigned num_bits)
 {
-       assert(num_bits <= bitreservoir_fill_size + 1);
+       assert(num_bits <= BITRESERVOIR_FILL_SIZE + 1);
 
        if (source->bits_available >= num_bits) {
                // Fast path (~90% of invocations?)
 
        if (source->bits_available >= num_bits) {
                // Fast path (~90% of invocations?)
@@ -63,13 +63,13 @@ static inline void possibly_refill(struct bit_source* source, unsigned num_bits)
        }
 
        // Slower path (~99% of remaining invocations?)
        }
 
        // Slower path (~99% of remaining invocations?)
-       assert(source->bits_available + bitreservoir_fill_size < bitreservoir_size);
+       assert(source->bits_available + BITRESERVOIR_FILL_SIZE < BITRESERVOIR_SIZE);
        if (source->bytes_available >= sizeof(bitreservoir_fill_t)) {
                bitreservoir_fill_t fill = read_bitreservoir_fill(source->bytes);
                source->bytes += sizeof(bitreservoir_fill_t);
                source->bytes_available -= sizeof(bitreservoir_fill_t);
        if (source->bytes_available >= sizeof(bitreservoir_fill_t)) {
                bitreservoir_fill_t fill = read_bitreservoir_fill(source->bytes);
                source->bytes += sizeof(bitreservoir_fill_t);
                source->bytes_available -= sizeof(bitreservoir_fill_t);
-               source->bits |= (bitreservoir_t)fill << (bitreservoir_size - bitreservoir_fill_size - source->bits_available);
-               source->bits_available += bitreservoir_fill_size;
+               source->bits |= (bitreservoir_t)fill << (BITRESERVOIR_SIZE - BITRESERVOIR_FILL_SIZE - source->bits_available);
+               source->bits_available += BITRESERVOIR_FILL_SIZE;
                return;
        }
 
                return;
        }
 
@@ -81,7 +81,7 @@ static inline void possibly_refill(struct bit_source* source, unsigned num_bits)
 static inline unsigned read_bits(struct bit_source* source, unsigned num_bits)
 {
        assert(source->bits_available >= num_bits);
 static inline unsigned read_bits(struct bit_source* source, unsigned num_bits)
 {
        assert(source->bits_available >= num_bits);
-       unsigned ret = (source->bits >> (bitreservoir_size - num_bits));
+       unsigned ret = (source->bits >> (BITRESERVOIR_SIZE - num_bits));
        source->bits <<= num_bits;
        source->bits_available -= num_bits;
        return ret;
        source->bits <<= num_bits;
        source->bits_available -= num_bits;
        return ret;