Check for large size first in the uncommon case of malloc.

Larger sizes are not that uncommon comparing to !tsd_fast.
This commit is contained in:
Qi Wang 2019-11-04 18:24:39 -08:00 committed by Qi Wang
parent 9c59abe42a
commit 836d7a7e69

View File

@ -2344,12 +2344,10 @@ je_malloc(size_t size) {
} }
tsd_t *tsd = tsd_get(false); tsd_t *tsd = tsd_get(false);
if (unlikely(!tsd || !tsd_fast(tsd) || (size > SC_LOOKUP_MAXCLASS))) { if (unlikely((size > SC_LOOKUP_MAXCLASS) || !tsd || !tsd_fast(tsd))) {
return malloc_default(size); return malloc_default(size);
} }
tcache_t *tcache = tsd_tcachep_get(tsd);
szind_t ind = sz_size2index_lookup(size); szind_t ind = sz_size2index_lookup(size);
/* /*
* The thread_allocated counter in tsd serves as a general purpose * The thread_allocated counter in tsd serves as a general purpose
@ -2373,6 +2371,7 @@ je_malloc(size_t size) {
return malloc_default(size); return malloc_default(size);
} }
tcache_t *tcache = tsd_tcachep_get(tsd);
cache_bin_t *bin = tcache_small_bin_get(tcache, ind); cache_bin_t *bin = tcache_small_bin_get(tcache, ind);
bool tcache_success; bool tcache_success;
void *ret = cache_bin_alloc_easy_reduced(bin, &tcache_success); void *ret = cache_bin_alloc_easy_reduced(bin, &tcache_success);