diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-05 16:08:26 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-05 16:08:26 +0300 |
commit | 247a28f242c2c0a8931a84df0db6e60763642f30 (patch) | |
tree | cdd5721ab333967a5b4e0489ded5f29bf48610b4 /source/blender/blenlib/BLI_stack.hh | |
parent | 5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d (diff) |
Revert "BLI: refactor how buffers for small object optimization are stored"
This reverts commit 5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d.
This was introducing build errors in windows. Need a bit more time to check it.
Diffstat (limited to 'source/blender/blenlib/BLI_stack.hh')
-rw-r--r-- | source/blender/blenlib/BLI_stack.hh | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/blenlib/BLI_stack.hh b/source/blender/blenlib/BLI_stack.hh index a5a95186e37..41c3be87265 100644 --- a/source/blender/blenlib/BLI_stack.hh +++ b/source/blender/blenlib/BLI_stack.hh @@ -106,7 +106,7 @@ class Stack { uint size_; /** The buffer used to implement small object optimization. */ - TypedBuffer<T, InlineBufferCapacity> inline_buffer_; + AlignedBuffer<sizeof(T) * InlineBufferCapacity, alignof(T)> inline_buffer_; /** * A chunk referencing the inline buffer. This is always the bottom-most chunk. @@ -123,12 +123,14 @@ class Stack { */ Stack(Allocator allocator = {}) : allocator_(allocator) { + T *inline_buffer = this->inline_buffer(); + inline_chunk_.below = nullptr; inline_chunk_.above = nullptr; - inline_chunk_.begin = inline_buffer_; - inline_chunk_.capacity_end = inline_buffer_ + InlineBufferCapacity; + inline_chunk_.begin = inline_buffer; + inline_chunk_.capacity_end = inline_buffer + InlineBufferCapacity; - top_ = inline_buffer_; + top_ = inline_buffer; top_chunk_ = &inline_chunk_; size_ = 0; } @@ -166,8 +168,8 @@ class Stack { Stack(Stack &&other) noexcept : Stack(other.allocator_) { - uninitialized_relocate_n<T>( - other.inline_buffer_, std::min(other.size_, InlineBufferCapacity), inline_buffer_); + uninitialized_relocate_n( + other.inline_buffer(), std::min(other.size_, InlineBufferCapacity), this->inline_buffer()); inline_chunk_.above = other.inline_chunk_.above; size_ = other.size_; @@ -178,7 +180,7 @@ class Stack { if (size_ <= InlineBufferCapacity) { top_chunk_ = &inline_chunk_; - top_ = inline_buffer_ + size_; + top_ = this->inline_buffer() + size_; } else { top_chunk_ = other.top_chunk_; @@ -337,6 +339,11 @@ class Stack { } private: + T *inline_buffer() const + { + return (T *)inline_buffer_.ptr(); + } + /** * Changes top_chunk_ to point to a new chunk that is above the current one. The new chunk might * be smaller than the given size_hint. This happens when a chunk that has been allocated before |