return pp->a;
}
case 1: {
- nibble *pp = (nibble*)(px + ( level / 2 ));
+ nibble *pp = (nibble*)( px + ( level / 2 ) );
switch ( level & 1 ) {
case 0: return pp->a;
case 1: return pp->b;
break;
}
case 2: {
- bitpair *pp = (bitpair*)(px + ( level / 4 ));
+ bitpair *pp = (bitpair*)( px + ( level / 4 ) );
switch ( level & 3 ) {
case 0: return pp->a;
case 1: return pp->b;
}
case 2: {
bitpair *pp = (bitpair*)( px + level / 4 );
- switch ( level & 0xf ) {
+ switch ( level & 3 ) {
case 0: return ++(pp->a);
case 1: return ++(pp->b);
case 2: return ++(pp->c);
// Set index to last value for all index parts at level and lower.
static void VECTOR_INDEX_LAST(vector *pv,vector_index *index, int level) {
- (*index) |= ONES >> ( 64 - VECTOR_BITS[ pv->variant ] * level );
+ static unsigned long ones[] = { 255, 15, 3 };
+ unsigned long x = ones[ pv->variant ];
+ while ( level-- ) {
+ (*index) |= x;
+ x <<= VECTOR_BITS[ pv->variant ];
+ }
+ // 255, 25, 3
+ //(*index) |= ONES >> ( 64 - ( VECTOR_BITS[ pv->variant ] * level ) );
}
// Return number of slots for a vector variant.
// If the page *p is all empty, so can/should be reclaimed.
} else {
if ( level > 0 ) {
- VECTOR_INDEX_FIRST( pv, index, level );
+ VECTOR_INDEX_FIRST( pv, index, level - 1 );
}
}
if ( VECTOR_INDEX_PART_INC( pv, index, level ) == 0 ) {
{
vector_index index = start;
while ( index < pv->size ) {
- void **slot = vector_next_used( pv, &index );
- if ( slot == 0 ) {
- break;
- }
int end = VECTOR_SLOTS( pv );
int i = index & ( end - 1 );
- for ( ; i < end && index < pv->size; i++, index++, slot++ ) {
- if ( itemfn( index, *slot, data ) ) {
+ for ( ; i < end && index < pv->size; i++, index++ ) {
+ void **slot = vector_access( pv, index, 0, 0 );
+ if ( slot && itemfn( index, *slot, data ) ) {
return;
}
}