Re: [PATCH 4/8] add functions for memory-efficient bitmaps

2014-07-01 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Sun, Jun 29, 2014 at 03:41:37AM -0400, Eric Sunshine wrote: +static inline void bitset_set(unsigned char *bits, int n) +{ + bits[n / CHAR_BIT] |= 1 (n % CHAR_BIT); +} Is it intentional or an oversight that there is no way to clear a bit in

Re: [PATCH 4/8] add functions for memory-efficient bitmaps

2014-07-01 Thread Jeff King
On Tue, Jul 01, 2014 at 09:57:13AM -0700, Junio C Hamano wrote: Another thing I noticed was that the definition of and the commentary on bitset_equal() and bitset_empty() sounded somewhat undecided. These functions take max that is deliberately named differently from num_bits (the width of

Re: [PATCH 4/8] add functions for memory-efficient bitmaps

2014-06-30 Thread Jeff King
On Sun, Jun 29, 2014 at 03:41:37AM -0400, Eric Sunshine wrote: +static inline void bitset_set(unsigned char *bits, int n) +{ + bits[n / CHAR_BIT] |= 1 (n % CHAR_BIT); +} Is it intentional or an oversight that there is no way to clear a bit in the set? Intentional in the sense

Re: [PATCH 4/8] add functions for memory-efficient bitmaps

2014-06-29 Thread Eric Sunshine
On Wed, Jun 25, 2014 at 7:40 PM, Jeff King p...@peff.net wrote: We already have a nice-to-use bitmap implementation in ewah/bitmap.c. It pretends to be infinitely long when asking for a bit (and just returns 0 for bits that haven't been allocated or set), and dynamically resizes as appropriate

Re: [PATCH 4/8] add functions for memory-efficient bitmaps

2014-06-26 Thread Jeff King
On Thu, Jun 26, 2014 at 05:15:05AM +0200, Torsten Bögershausen wrote: + */ +static inline int bitset_sizeof(int num_bits) +{ + return (num_bits + CHAR_BIT - 1) / CHAR_BIT; +} Just a general question about the usage of int here (and at other places): Is there a special reason for new

[PATCH 4/8] add functions for memory-efficient bitmaps

2014-06-25 Thread Jeff King
We already have a nice-to-use bitmap implementation in ewah/bitmap.c. It pretends to be infinitely long when asking for a bit (and just returns 0 for bits that haven't been allocated or set), and dynamically resizes as appropriate when you set bits. The cost to this is that each bitmap must store

Re: [PATCH 4/8] add functions for memory-efficient bitmaps

2014-06-25 Thread Torsten Bögershausen
On 2014-06-26 01.40, Jeff King wrote: [] + */ +static inline int bitset_sizeof(int num_bits) +{ + return (num_bits + CHAR_BIT - 1) / CHAR_BIT; +} Just a general question about the usage of int here (and at other places): Is there a special reason for new code to allow num_bits to be