diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-11-03 10:33:52 +0330 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-11-17 20:13:04 +0330 |
commit | 48a4c9c1adb6c5b3e0e602d3d8214291eea6b429 (patch) | |
tree | c56f2996a4c067da4b756c90b1c91878ffcfd050 /AK/Vector.h | |
parent | 6970bf03a963e9408bdf5a9cb7e377ea5a91545d (diff) | |
download | serenity-48a4c9c1adb6c5b3e0e602d3d8214291eea6b429.zip |
AK: Use TypedTransfer to move vector's inline buffer
This avoids an explicit loop-move when the type is trivial.
Diffstat (limited to 'AK/Vector.h')
-rw-r--r-- | AK/Vector.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/AK/Vector.h b/AK/Vector.h index c56761e369..1b4c4713fa 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -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; |