From 05cb499d58bfc2b64fe00c3362d71beb5f3c9494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Thu, 25 Nov 2021 00:18:46 +0100 Subject: [PATCH] AK: Add Vector::unchecked_append for data pointers This mirrors the existence of append() for data pointers and is very useful when the program needs to have a guarantee of no allocations, as is necessary for real-time audio. --- AK/Vector.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/AK/Vector.h b/AK/Vector.h index 22749d61222..751952b987b 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -253,6 +253,15 @@ public: ++m_size; } + ALWAYS_INLINE void unchecked_append(StorageType const* values, size_t count) + { + if (count == 0) + return; + VERIFY((size() + count) <= capacity()); + TypedTransfer::copy(slot(m_size), values, count); + m_size += count; + } + template void empend(Args&&... args) requires(!contains_reference) {