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:
authorJacques Lucke <jacques@blender.org>2020-07-05 16:08:26 +0300
committerJacques Lucke <jacques@blender.org>2020-07-05 16:08:26 +0300
commit247a28f242c2c0a8931a84df0db6e60763642f30 (patch)
treecdd5721ab333967a5b4e0489ded5f29bf48610b4 /source/blender/blenlib/BLI_array.hh
parent5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d (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_array.hh')
-rw-r--r--source/blender/blenlib/BLI_array.hh15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh
index 9732f43a268..ee4e9702779 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. */
- TypedBuffer<T, InlineBufferCapacity> inline_buffer_;
+ AlignedBuffer<sizeof(T) * InlineBufferCapacity, alignof(T)> inline_buffer_;
public:
/**
@@ -82,7 +82,7 @@ class Array {
*/
Array()
{
- data_ = inline_buffer_;
+ data_ = this->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,13 +335,18 @@ class Array {
T *get_buffer_for_size(uint size)
{
if (size <= InlineBufferCapacity) {
- return inline_buffer_;
+ return this->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);
@@ -349,7 +354,7 @@ class Array {
bool uses_inline_buffer() const
{
- return data_ == inline_buffer_;
+ return data_ == this->inline_buffer();
}
};