From 247a28f242c2c0a8931a84df0db6e60763642f30 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sun, 5 Jul 2020 15:08:26 +0200 Subject: 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. --- source/blender/blenlib/BLI_stack.hh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source/blender/blenlib/BLI_stack.hh') 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 inline_buffer_; + AlignedBuffer 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( - 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 -- cgit v1.2.3