BLI: slight Vector move constructor improvement
`OtherInlineBufferCapacity <= InlineBufferCapacity` implies `size <= InlineBufferCapacity` and can be done at compile time. So if that is true already (as it commonly is), the `else` branch is not necessary. This can improve performance in theory, although I couldn't measure that in practice. Additionally, this change also reduces the binary size (because of the omitted else branch). Since this code is inlined fairly often, the impact is measurable: the binary size is reduced by 50kb.
This commit is contained in:
@@ -243,7 +243,9 @@ class Vector {
|
||||
const int64_t size = other.size();
|
||||
|
||||
if (other.is_inline()) {
|
||||
if (size <= InlineBufferCapacity) {
|
||||
/* This first check is not strictly necessary, but improves performance because it can be
|
||||
* done at compile time and makes the size check at run-time unnecessary. */
|
||||
if (OtherInlineBufferCapacity <= InlineBufferCapacity || size <= InlineBufferCapacity) {
|
||||
/* Copy between inline buffers. */
|
||||
uninitialized_relocate_n(other.begin_, size, begin_);
|
||||
end_ = begin_ + size;
|
||||
|
||||
Reference in New Issue
Block a user