summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-01-14 13:50:09 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-01-14 13:50:54 +0000
commita772cb05a682fd05fabd0d571417ec7976d0165d (patch)
tree7b81ef07e84c8f1e9c14934ccaa2ab85645eb2d5 /vespalib
parent6ddc242f9ab1331c9bf0d5ce373a7a4e3b153196 (diff)
Avoid swap. Inline and use anonymous namespaces for better code generation.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp
index 01d0f91dfa3..6aa96992254 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.cpp
+++ b/vespalib/src/vespa/vespalib/util/alloc.cpp
@@ -116,6 +116,7 @@ MMapLimitAndAlignment::MMapLimitAndAlignment(size_t mmapLimit, size_t alignment)
}
namespace alloc {
+namespace {
class HeapAllocator : public MemoryAllocator {
public:
@@ -179,8 +180,6 @@ private:
};
-namespace {
-
struct MMapLimitAndAlignmentHash {
std::size_t operator ()(MMapLimitAndAlignment key) const { return key.hash(); }
};
@@ -239,8 +238,6 @@ alloc::AlignedHeapAllocator _G_1KalignedHeapAllocator(4096);
alloc::AlignedHeapAllocator _G_512BalignedHeapAllocator(512);
alloc::MMapAllocator _G_mmapAllocatorDefault;
-}
-
MemoryAllocator &
HeapAllocator::getDefault() {
return _G_heapAllocatorDefault;
@@ -270,7 +267,8 @@ AutoAllocator::getDefault() {
return *_G_availableAutoAllocators.second;
}
-MemoryAllocator & AutoAllocator::getAllocator(size_t mmapLimit, size_t alignment) {
+MemoryAllocator &
+AutoAllocator::getAllocator(size_t mmapLimit, size_t alignment) {
return getAutoAllocator(_G_availableAutoAllocators.first, mmapLimit, alignment);
}
@@ -451,6 +449,9 @@ AutoAllocator::free(PtrAndSize alloc) const {
}
}
+}
+
+
Alloc
Alloc::allocHeap(size_t sz)
{