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-06 11:56:26 +0300
committerJacques Lucke <jacques@blender.org>2020-07-06 11:56:26 +0300
commit703a73fa846531a0888c8f99489c8e213f5c5d81 (patch)
tree00c833f690d953e825a32edbc03cf9572981cc6c /source/blender/blenlib/BLI_vector.hh
parent80393a0ebadc7b8e825a6ce64204bf4424650fe5 (diff)
BLI: refactor how buffers for small object optimization are stored
Previously, there was an error when operator-> was returning an invalid type. See error C2839.
Diffstat (limited to 'source/blender/blenlib/BLI_vector.hh')
-rw-r--r--source/blender/blenlib/BLI_vector.hh19
1 files changed, 7 insertions, 12 deletions
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index a06be65685f..e4f5afe661d 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -92,7 +92,7 @@ class Vector {
Allocator allocator_;
/** A placeholder buffer that will remain uninitialized until it is used. */
- AlignedBuffer<(uint)sizeof(T) * InlineBufferCapacity, (uint)alignof(T)> inline_buffer_;
+ TypedBuffer<T, InlineBufferCapacity> inline_buffer_;
/**
* Store the size of the vector explicitly in debug builds. Otherwise you'd always have to call
@@ -120,7 +120,7 @@ class Vector {
*/
Vector()
{
- begin_ = this->inline_buffer();
+ begin_ = inline_buffer_;
end_ = begin_;
capacity_end_ = begin_ + InlineBufferCapacity;
UPDATE_VECTOR_SIZE(this);
@@ -227,7 +227,7 @@ class Vector {
if (other.is_inline()) {
if (size <= InlineBufferCapacity) {
/* Copy between inline buffers. */
- begin_ = this->inline_buffer();
+ begin_ = inline_buffer_;
end_ = begin_ + size;
capacity_end_ = begin_ + InlineBufferCapacity;
uninitialized_relocate_n(other.begin_, size, begin_);
@@ -248,7 +248,7 @@ class Vector {
capacity_end_ = other.capacity_end_;
}
- other.begin_ = other.inline_buffer();
+ other.begin_ = other.inline_buffer_;
other.end_ = other.begin_;
other.capacity_end_ = other.begin_ + OtherInlineBufferCapacity;
UPDATE_VECTOR_SIZE(this);
@@ -399,7 +399,7 @@ class Vector {
allocator_.deallocate(begin_);
}
- begin_ = this->inline_buffer();
+ begin_ = inline_buffer_;
end_ = begin_;
capacity_end_ = begin_ + InlineBufferCapacity;
UPDATE_VECTOR_SIZE(this);
@@ -763,14 +763,9 @@ class Vector {
}
private:
- T *inline_buffer() const
- {
- return (T *)inline_buffer_.ptr();
- }
-
bool is_inline() const
{
- return begin_ == this->inline_buffer();
+ return begin_ == inline_buffer_;
}
void ensure_space_for_one()
@@ -817,7 +812,7 @@ class Vector {
uint capacity;
if (size <= InlineBufferCapacity) {
- begin_ = this->inline_buffer();
+ begin_ = inline_buffer_;
capacity = InlineBufferCapacity;
}
else {