diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-05 17:30:26 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-05 17:30:26 +0300 |
commit | 5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d (patch) | |
tree | 333d19482218b868d0a602fd3c7869551a94d632 /source/blender/blenlib/BLI_array.hh | |
parent | 464aaf27016fdaeae94f701195c289660cf4474e (diff) |
BLI: refactor how buffers for small object optimization are stored
Diffstat (limited to 'source/blender/blenlib/BLI_array.hh')
-rw-r--r-- | source/blender/blenlib/BLI_array.hh | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh index ee4e9702779..9732f43a268 100644 --- a/source/blender/blenlib/BLI_array.hh +++ b/source/blender/blenlib/BLI_array.hh @@ -74,7 +74,7 @@ class Array { Allocator allocator_; /** A placeholder buffer that will remain uninitialized until it is used. */ - AlignedBuffer<sizeof(T) * InlineBufferCapacity, alignof(T)> inline_buffer_; + TypedBuffer<T, InlineBufferCapacity> inline_buffer_; public: /** @@ -82,7 +82,7 @@ class Array { */ Array() { - data_ = this->inline_buffer(); + data_ = inline_buffer_; size_ = 0; } @@ -167,7 +167,7 @@ class Array { uninitialized_relocate_n(other.data_, size_, data_); } - other.data_ = other.inline_buffer(); + other.data_ = other.inline_buffer_; other.size_ = 0; } @@ -335,18 +335,13 @@ class Array { T *get_buffer_for_size(uint size) { if (size <= InlineBufferCapacity) { - return this->inline_buffer(); + return inline_buffer_; } else { return this->allocate(size); } } - T *inline_buffer() const - { - return (T *)inline_buffer_.ptr(); - } - T *allocate(uint size) { return (T *)allocator_.allocate(size * sizeof(T), alignof(T), AT); @@ -354,7 +349,7 @@ class Array { bool uses_inline_buffer() const { - return data_ == this->inline_buffer(); + return data_ == inline_buffer_; } }; |