Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/BLI_stack.hh')
-rw-r--r--source/blender/blenlib/BLI_stack.hh21
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