Lines Matching refs:ht
42 static int hash_may_resize(hashtab_T *ht, int minitems);
52 hashtab_T *ht;
54 ht = ALLOC_ONE(hashtab_T);
55 if (ht != NULL)
56 hash_init(ht);
57 return ht;
65 hash_init(hashtab_T *ht) in hash_init() argument
68 CLEAR_POINTER(ht); in hash_init()
69 ht->ht_array = ht->ht_smallarray; in hash_init()
70 ht->ht_mask = HT_INIT_SIZE - 1; in hash_init()
78 hash_clear(hashtab_T *ht) in hash_clear() argument
80 if (ht->ht_array != ht->ht_smallarray) in hash_clear()
81 vim_free(ht->ht_array); in hash_clear()
91 hash_clear_all(hashtab_T *ht, int off) in hash_clear_all() argument
96 todo = (long)ht->ht_used; in hash_clear_all()
97 for (hi = ht->ht_array; todo > 0; ++hi) in hash_clear_all()
105 hash_clear(ht); in hash_clear_all()
118 hash_find(hashtab_T *ht, char_u *key) in hash_find() argument
120 return hash_lookup(ht, key, hash_hash(key)); in hash_find()
127 hash_lookup(hashtab_T *ht, char_u *key, hash_T hash) in hash_lookup() argument
144 idx = (unsigned)(hash & ht->ht_mask); in hash_lookup()
145 hi = &ht->ht_array[idx]; in hash_lookup()
171 hi = &ht->ht_array[idx & ht->ht_mask]; in hash_lookup()
207 hash_add(hashtab_T *ht, char_u *key) in hash_add() argument
212 hi = hash_lookup(ht, key, hash); in hash_add()
218 return hash_add_item(ht, hi, key, hash); in hash_add()
229 hashtab_T *ht, in hash_add_item() argument
235 if (ht->ht_error && hash_may_resize(ht, 0) == FAIL) in hash_add_item()
238 ++ht->ht_used; in hash_add_item()
239 ++ht->ht_changed; in hash_add_item()
241 ++ht->ht_filled; in hash_add_item()
246 return hash_may_resize(ht, 0); in hash_add_item()
272 hash_remove(hashtab_T *ht, hashitem_T *hi) in hash_remove() argument
274 --ht->ht_used; in hash_remove()
275 ++ht->ht_changed; in hash_remove()
277 hash_may_resize(ht, 0); in hash_remove()
286 hash_lock(hashtab_T *ht) in hash_lock() argument
288 ++ht->ht_locked; in hash_lock()
297 hash_lock_size(hashtab_T *ht, int size) in hash_lock_size() argument
299 (void)hash_may_resize(ht, size); in hash_lock_size()
300 ++ht->ht_locked; in hash_lock_size()
309 hash_unlock(hashtab_T *ht) in hash_unlock() argument
311 --ht->ht_locked; in hash_unlock()
312 (void)hash_may_resize(ht, 0); in hash_unlock()
322 hashtab_T *ht, in hash_may_resize() argument
336 if (ht->ht_locked > 0) in hash_may_resize()
340 if (ht->ht_used > ht->ht_filled) in hash_may_resize()
342 if (ht->ht_filled >= ht->ht_mask + 1) in hash_may_resize()
350 if (ht->ht_filled < HT_INIT_SIZE - 1 in hash_may_resize()
351 && ht->ht_array == ht->ht_smallarray) in hash_may_resize()
360 oldsize = ht->ht_mask + 1; in hash_may_resize()
361 if (ht->ht_filled * 3 < oldsize * 2 && ht->ht_used > oldsize / 5) in hash_may_resize()
364 if (ht->ht_used > 1000) in hash_may_resize()
365 minsize = ht->ht_used * 2; // it's big, don't make too much room in hash_may_resize()
367 minsize = ht->ht_used * 4; // make plenty of room in hash_may_resize()
372 if ((long_u)minitems < ht->ht_used) // just in case... in hash_may_resize()
373 minitems = (int)ht->ht_used; in hash_may_resize()
388 newarray = ht->ht_smallarray; in hash_may_resize()
389 if (ht->ht_array == newarray) in hash_may_resize()
398 oldarray = ht->ht_array; in hash_may_resize()
399 CLEAR_FIELD(ht->ht_smallarray); in hash_may_resize()
410 if (ht->ht_filled < ht->ht_mask) in hash_may_resize()
412 ht->ht_error = TRUE; in hash_may_resize()
415 oldarray = ht->ht_array; in hash_may_resize()
424 todo = (int)ht->ht_used; in hash_may_resize()
448 if (ht->ht_array != ht->ht_smallarray) in hash_may_resize()
449 vim_free(ht->ht_array); in hash_may_resize()
450 ht->ht_array = newarray; in hash_may_resize()
451 ht->ht_mask = newmask; in hash_may_resize()
452 ht->ht_filled = ht->ht_used; in hash_may_resize()
453 ++ht->ht_changed; in hash_may_resize()
454 ht->ht_error = FALSE; in hash_may_resize()