1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 02:07:35 +00:00

AK: Use TypedTransfer to move vector's inline buffer

This avoids an explicit loop-move when the type is trivial.
This commit is contained in:
Ali Mohammad Pur 2022-11-03 10:33:52 +03:30 committed by Ali Mohammad Pur
parent 6970bf03a9
commit 48a4c9c1ad
2 changed files with 17 additions and 6 deletions

View file

@ -73,10 +73,8 @@ public:
{
if constexpr (inline_capacity > 0) {
if (!m_outline_buffer) {
for (size_t i = 0; i < m_size; ++i) {
new (&inline_buffer()[i]) StorageType(move(other.inline_buffer()[i]));
other.inline_buffer()[i].~StorageType();
}
TypedTransfer<T>::move(inline_buffer(), other.inline_buffer(), m_size);
TypedTransfer<T>::delete_(other.inline_buffer(), m_size);
}
}
other.m_outline_buffer = nullptr;