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:
Jacques Lucke
2024-12-13 12:48:35 +01:00
parent f2949d387c
commit 55cc2fcd46

View File

@@ -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;