Commit 584333c5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Polish this to the new more general usage:

Allocate smaller lumps.
Don't extend to clear bits.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2770 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 3f4bbc13
......@@ -38,7 +38,7 @@
*/
#define VBITMAP_TYPE unsigned /* Our preferred wordsize */
#define VBITMAP_LUMP (32*1024) /* How many bits we alloc at a time */
#define VBITMAP_LUMP (1024) /* How many bits we alloc at a time */
#define VBITMAP_WORD (sizeof(VBITMAP_TYPE) * 8)
#define VBITMAP_IDX(n) (n / VBITMAP_WORD)
#define VBITMAP_BIT(n) (1U << (n % VBITMAP_WORD))
......@@ -88,9 +88,8 @@ static inline void
vbit_clr(struct vbitmap *vb, unsigned bit)
{
if (bit >= vb->nbits)
vbit_expand(vb, bit);
vb->bits[VBITMAP_IDX(bit)] &= ~VBITMAP_BIT(bit);
if (bit < vb->nbits)
vb->bits[VBITMAP_IDX(bit)] &= ~VBITMAP_BIT(bit);
}
static inline int
......@@ -98,6 +97,6 @@ vbit_test(struct vbitmap *vb, unsigned bit)
{
if (bit >= vb->nbits)
vbit_expand(vb, bit);
return (0);
return (vb->bits[VBITMAP_IDX(bit)] & VBITMAP_BIT(bit));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment