예제 #1
0
파일: Hash.c 프로젝트: hernan604/lucy
static CFISH_INLINE HashEntry*
SI_rebuild_hash(Hash *self) {
    HashEntry *old_entries = (HashEntry*)self->entries;
    HashEntry *entry       = old_entries;
    HashEntry *limit       = old_entries + self->capacity;

    SI_kill_iter(self);
    self->capacity *= 2;
    self->threshold = (self->capacity / 3) * 2;
    self->entries   = (HashEntry*)CALLOCATE(self->capacity, sizeof(HashEntry));
    self->size      = 0;

    for (; entry < limit; entry++) {
        if (!entry->key || entry->key == (Obj*)TOMBSTONE) {
            continue;
        }
        Hash_do_store(self, entry->key, entry->value,
                      entry->hash_sum, true);
    }

    FREEMEM(old_entries);

    return (HashEntry*)self->entries;
}
예제 #2
0
파일: Hash.c 프로젝트: hernan604/lucy
void
Hash_Store_IMP(Hash *self, Obj *key, Obj *value) {
    Hash_do_store(self, key, value, Obj_Hash_Sum(key), false);
}
예제 #3
0
파일: Hash.c 프로젝트: hernan604/lucy
void
Hash_Store_Utf8_IMP(Hash *self, const char *key, size_t key_len, Obj *value) {
    StackString *key_buf = SSTR_WRAP_UTF8((char*)key, key_len);
    Hash_do_store(self, (Obj*)key_buf, value,
                  SStr_Hash_Sum(key_buf), false);
}
예제 #4
0
파일: Hash.c 프로젝트: pavansondur/lucy
void
Hash_store_str(Hash *self, const char *key, size_t key_len, Obj *value) {
    ZombieCharBuf *key_buf = ZCB_WRAP_STR((char*)key, key_len);
    Hash_do_store(self, (Obj*)key_buf, value,
                  ZCB_Hash_Sum(key_buf), false);
}