From: Ralph Ronnquist Date: Sun, 10 Jul 2022 14:41:20 +0000 (+1000) Subject: change tupleitem key to be column matched with null items. X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=38d995cc2631a97c56494cc2d545e51ad60e618c;p=rrq%2Frrqmisc.git change tupleitem key to be column matched with null items. --- diff --git a/vector/tupleitem.c b/vector/tupleitem.c index f3dfe2c..2a4a01a 100644 --- a/vector/tupleitem.c +++ b/vector/tupleitem.c @@ -32,10 +32,9 @@ static unsigned long tupleitem_hashcode(void *this,void *key) { value <<= 3; if ( (*kp)[i] ) { value += COLUMN[i]->hashcode( COLUMN[i], (*kp)[i] ); - } else { - value += 17; } } + value += 17; } return value; } @@ -67,17 +66,12 @@ static int tupleitem_haskey(void *this,void *item,void *key) { static void *tupleitem_itemkey(void *this,void *item) { tupleschema *def = (tupleschema *) this; tuple *tp = (tuple*) item; - int i, j; - int keylen = 0; - for ( i = 0 ; i < def->arity; i++ ) { - if ( COLUMN[i] ) { - keylen++; - } - } + int i; + int keylen = def->arity; void **parts = calloc( keylen, sizeof( void* ) ); - for ( i = 0, j = 0; i < def->arity; i++ ) { + for ( i = 0; i < def->arity; i++ ) { if ( COLUMN[i] ) { - parts[j++] = COLUMN[i]->itemkey( COLUMN[i], (*tp)[i] ); + parts[i] = COLUMN[i]->itemkey( COLUMN[i], (*tp)[i] ); } } return (void*) parts; @@ -90,10 +84,10 @@ static void *tupleitem_itemkey(void *this,void *item) { static void tupleitem_releasekey(void *this,void *key) { tupleschema *def = (tupleschema *) this; tuple *kp = (tuple*) key; - int i,j; - for ( i = 0, j = 0; i < def->arity; i++ ) { + int i; + for ( i = 0; i < def->arity; i++ ) { if ( COLUMN[i] ) { - COLUMN[i]->releasekey( COLUMN[i], (*kp)[j++] ); + COLUMN[i]->releasekey( COLUMN[i], (*kp)[i] ); } } free( key );