diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-02 10:53:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 10:53:29 +0200 |
commit | 1c8b25da9672c2a1c8b17bbd7741645b8e21a0e9 (patch) | |
tree | 156de7c4fbf64ef2000fbfd282641534688e63b3 /vespalib | |
parent | 31a2c8c9026f1c937eeda8e5ebfbf0144e5c8b63 (diff) | |
parent | 43f78d0bdbd2d73e6c43baeea48fcc5290afcc12 (diff) |
Merge pull request #22859 from vespa-engine/balder/most-likely-branch-should-be-first
If all else is equal the compiler will assume the if branch is more l…
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/alloc.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 0a83d39ca09..8240fa2d8e6 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -228,6 +228,9 @@ getDefaultAutoAllocator(AutoAllocatorsMap & map) { } AutoAllocatorsMapWithDefault +createAutoAllocatorsWithDefault() __attribute__((noinline)); + +AutoAllocatorsMapWithDefault createAutoAllocatorsWithDefault() { AutoAllocatorsMapWithDefault tmp(createAutoAllocators(), nullptr); tmp.second = &getDefaultAutoAllocator(tmp.first); @@ -454,33 +457,33 @@ AutoAllocator::resize_inplace(PtrAndSize current, size_t newSize) const { MMapAllocator::PtrAndSize AutoAllocator::alloc(size_t sz) const { - if (useMMap(sz)) { - sz = roundUpToHugePages(sz); - return MMapAllocator::salloc(sz, nullptr); - } else { + if ( ! useMMap(sz)) { if (_alignment == 0) { return HeapAllocator::salloc(sz); } else { return AlignedHeapAllocator(_alignment).alloc(sz); } + } else { + sz = roundUpToHugePages(sz); + return MMapAllocator::salloc(sz, nullptr); } } void AutoAllocator::free(PtrAndSize alloc) const { - if (isMMapped(alloc.second)) { - return MMapAllocator::sfree(alloc); - } else { + if ( ! isMMapped(alloc.second)) { return HeapAllocator::sfree(alloc); + } else { + return MMapAllocator::sfree(alloc); } } void AutoAllocator::free(void * ptr, size_t sz) const { - if (useMMap(sz)) { - return MMapAllocator::sfree(PtrAndSize(ptr, roundUpToHugePages(sz))); - } else { + if ( ! useMMap(sz)) { return HeapAllocator::sfree(PtrAndSize(ptr, sz)); + } else { + return MMapAllocator::sfree(PtrAndSize(ptr, roundUpToHugePages(sz))); } } |