long Bucket_quick_store(DictBucket * bucketp, Optr key, Optr value) { long i; DictBucket bucket = *bucketp; uns_int tally = bucket->tally; for (i = 0; i < tally; i = i+2) { if (key == bucket->values[i]) { bucket->values[i+1] = value; return 0; } } for (i = 0; i < tally; i = i+2) { switch (Bucket_quick_compare_key(key, bucket->values[i])) { case -1: assert1(NULL, "Invalid key for quickstore!\n"); case 1: bucket->values[i+1] = value; return 0; } } if (tally == bucket->size) { Bucket_grow(bucketp); bucket = *bucketp; } bucket->values[tally] = key; bucket->values[tally+1] = value; bucket->tally = tally+2; return 1; }
static int merge_output(Bucket *r, SetIteration *i, int mapping) { if (r->len >= r->size && Bucket_grow(r, -1, !mapping) < 0) return -1; COPY_KEY(r->keys[r->len], i->key); INCREF_KEY(r->keys[r->len]); if (mapping) { COPY_VALUE(r->values[r->len], i->value); INCREF_VALUE(r->values[r->len]); } r->len++; return 0; }