diff options
author | Jack Lloyd <[email protected]> | 2018-03-08 18:15:27 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-08 18:15:27 -0500 |
commit | 0c90eef7580ebd8c605c76ab2d3170d01c462bb9 (patch) | |
tree | 3da44b56a62c7ddc1dddd1d6d46c048feeb547fa /src/lib | |
parent | 69b53b714b5bac4298a90f42753202d687bac8e8 (diff) |
Small fiddly optimizations in locking_allocator
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/utils/locking_allocator/locking_allocator.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/utils/locking_allocator/locking_allocator.cpp b/src/lib/utils/locking_allocator/locking_allocator.cpp index c7ca1662f..e457a203c 100644 --- a/src/lib/utils/locking_allocator/locking_allocator.cpp +++ b/src/lib/utils/locking_allocator/locking_allocator.cpp @@ -17,15 +17,15 @@ namespace Botan { namespace { -bool ptr_in_pool(const void* pool_ptr, size_t poolsize, - const void* buf_ptr, size_t bufsize) +inline bool ptr_in_pool(const void* pool_ptr, size_t poolsize, + const void* buf_ptr, size_t bufsize) { const uintptr_t pool = reinterpret_cast<uintptr_t>(pool_ptr); const uintptr_t buf = reinterpret_cast<uintptr_t>(buf_ptr); return (buf >= pool) && (buf + bufsize <= pool + poolsize); } -size_t padding_for_alignment(size_t offset, size_t desired_alignment) +inline size_t padding_for_alignment(size_t offset, size_t desired_alignment) { size_t mod = offset % desired_alignment; if(mod == 0) @@ -70,8 +70,9 @@ void* mlock_allocator::allocate(size_t num_elems, size_t elem_size) return m_pool + offset; } - if((i->second >= (n + padding_for_alignment(i->first, alignment)) && - ((best_fit == m_freelist.end()) || (best_fit->second > i->second)))) + + if(((best_fit == m_freelist.end()) || (best_fit->second > i->second)) && + (i->second >= (n + padding_for_alignment(i->first, alignment)))) { best_fit = i; } |