Remove a branch from cache_bin_alloc_easy
Combine the branches for checking for an empty cache_bin, and checking for the low watermark.
This commit is contained in:
parent
856319dc8a
commit
09adf18f1a
@ -88,11 +88,21 @@ JEMALLOC_ALWAYS_INLINE void *
|
|||||||
cache_bin_alloc_easy(cache_bin_t *bin, bool *success) {
|
cache_bin_alloc_easy(cache_bin_t *bin, bool *success) {
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
if (unlikely(bin->ncached == 0)) {
|
bin->ncached--;
|
||||||
bin->low_water = -1;
|
|
||||||
|
/*
|
||||||
|
* Check for both bin->ncached == 0 and ncached < low_water
|
||||||
|
* in a single branch.
|
||||||
|
*/
|
||||||
|
if (unlikely(bin->ncached <= bin->low_water)) {
|
||||||
|
bin->low_water = bin->ncached;
|
||||||
|
if (bin->ncached == -1) {
|
||||||
|
bin->ncached = 0;
|
||||||
*success = false;
|
*success = false;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* success (instead of ret) should be checked upon the return of this
|
* success (instead of ret) should be checked upon the return of this
|
||||||
* function. We avoid checking (ret == NULL) because there is never a
|
* function. We avoid checking (ret == NULL) because there is never a
|
||||||
@ -101,12 +111,7 @@ cache_bin_alloc_easy(cache_bin_t *bin, bool *success) {
|
|||||||
* cacheline).
|
* cacheline).
|
||||||
*/
|
*/
|
||||||
*success = true;
|
*success = true;
|
||||||
ret = *(bin->avail - bin->ncached);
|
ret = *(bin->avail - (bin->ncached + 1));
|
||||||
bin->ncached--;
|
|
||||||
|
|
||||||
if (unlikely(bin->ncached < bin->low_water)) {
|
|
||||||
bin->low_water = bin->ncached;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user