From: Ralph Ronnquist Date: Sun, 26 Jun 2022 05:46:29 +0000 (+1000) Subject: debug vector_iterate for 4-bit levels X-Git-Tag: 0.1~9 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=015671d15f553787f4462906f8ddf8d63a0c710a;p=rrq%2Frrqmisc.git debug vector_iterate for 4-bit levels --- diff --git a/vector/vector.c b/vector/vector.c index 129ba02..feaed9f 100644 --- a/vector/vector.c +++ b/vector/vector.c @@ -15,6 +15,8 @@ typedef union { } __attribute__ ((__packed__)) as_byte[8]; } vector_indexing; +#define VECTOR_LEVEL_MASK ( VECTOR_SLOTS - 1 ) + #define VECTOR_PART_BYTE(i,p) ((vector_indexing*)(i))->as_byte[ (p)/2 ] static int VECTOR_INDEX_PART(vector_index *index,int part) { @@ -359,7 +361,7 @@ void vector_iterate(vector *pv, if ( slot == 0 ) { break; } - int i = index & 0xff; + int i = index & VECTOR_LEVEL_MASK ; for ( ; i < VECTOR_SLOTS && index < pv->size; i++, index++, slot++ ) { if ( itemfn( index, *slot, data ) ) { return;