summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-09 05:44:43 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-09 05:44:43 +0000
commit1cb390424a1e9b783115df7b3f4155f9480a0b2f (patch)
treed8ae16c41fdb085db75e249d30f7d094cad0f7b6 /eval
parent773690028ded4e47e36102d82ce5a705826b7181 (diff)
Deinline expensive methods.
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/fast_value.hpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/eval/src/vespa/eval/eval/fast_value.hpp b/eval/src/vespa/eval/eval/fast_value.hpp
index 8b2c69fa042..fef25f0d8c9 100644
--- a/eval/src/vespa/eval/eval/fast_value.hpp
+++ b/eval/src/vespa/eval/eval/fast_value.hpp
@@ -169,23 +169,16 @@ struct FastCells {
size_t capacity;
size_t size;
mutable alloc::Alloc memory;
- FastCells(size_t initial_capacity)
- : capacity(roundUp2inN(initial_capacity)),
- size(0),
- memory(alloc::Alloc::alloc(elem_size * capacity))
- {
- static_assert(std::is_trivially_copyable_v<T>);
- static_assert(can_skip_destruction<T>::value);
- }
- ~FastCells() = default;
+ FastCells(size_t initial_capacity);
+ FastCells(const FastCells &) = delete;
+ FastCells & operator = (const FastCells &) = delete;
+ ~FastCells();
void ensure_free(size_t need) {
if (__builtin_expect((size + need) > capacity, false)) {
- capacity = roundUp2inN(size + need);
- alloc::Alloc new_memory = alloc::Alloc::alloc(elem_size * capacity);
- memcpy(new_memory.get(), memory.get(), elem_size * size);
- memory = std::move(new_memory);
+ reallocate(need);
}
}
+ void reallocate(size_t need);
constexpr T *get(size_t offset) const {
return reinterpret_cast<T*>(memory.get()) + offset;
}
@@ -206,6 +199,28 @@ struct FastCells {
}
};
+template <typename T>
+FastCells<T>::FastCells(size_t initial_capacity)
+ : capacity(roundUp2inN(initial_capacity)),
+ size(0),
+ memory(alloc::Alloc::alloc(elem_size * capacity))
+{
+ static_assert(std::is_trivially_copyable_v<T>);
+ static_assert(can_skip_destruction<T>::value);
+}
+
+template <typename T>
+void
+FastCells<T>::reallocate(size_t need) {
+ capacity = roundUp2inN(size + need);
+ alloc::Alloc new_memory = alloc::Alloc::alloc(elem_size * capacity);
+ memcpy(new_memory.get(), memory.get(), elem_size * size);
+ memory = std::move(new_memory);
+}
+
+template <typename T>
+FastCells<T>::~FastCells() = default;
+
//-----------------------------------------------------------------------------
template <typename T, bool transient>