diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
| commit | a201939a8150bc4c2f221925797ea2751c74b77c (patch) | |
| tree | 26fee4ec601319fd8771435087931023e393fe92 /stdlib/tables.c | |
| parent | 683b0f5141ad21914d77cd4b4b81e7e2161f90f3 (diff) | |
Use likely()/unlikely() macros and a few bugfixes for integers
Diffstat (limited to 'stdlib/tables.c')
| -rw-r--r-- | stdlib/tables.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stdlib/tables.c b/stdlib/tables.c index 449f37ca..38e98ccc 100644 --- a/stdlib/tables.c +++ b/stdlib/tables.c @@ -200,7 +200,7 @@ static void Table$set_bucket(Table_t *t, const void *entry, int32_t index, const static void hashmap_resize_buckets(Table_t *t, uint32_t new_capacity, const TypeInfo_t *type) { - if (__builtin_expect(new_capacity > TABLE_MAX_BUCKETS, 0)) + if (unlikely(new_capacity > TABLE_MAX_BUCKETS)) fail("Table has exceeded the maximum table size (2^31) and cannot grow further!"); hdebug("About to resize from %u to %u\n", t->bucket_info ? t->bucket_info->count : 0, new_capacity); hshow(t); @@ -252,7 +252,7 @@ public void *Table$reserve(Table_t *t, const void *key, const void *value, const // Resize buckets if necessary if (t->entries.length >= (int64_t)t->bucket_info->count) { uint32_t newsize = (uint32_t)t->bucket_info->count + MIN((uint32_t)t->bucket_info->count, 64); - if (__builtin_expect(newsize > TABLE_MAX_BUCKETS, 0)) + if (unlikely(newsize > TABLE_MAX_BUCKETS)) newsize = t->entries.length + 1; hashmap_resize_buckets(t, newsize, type); } |
