From b805f112c21a1e5bae8d66caa1d640ad2d5e6f5f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 27 Jul 2019 17:43:00 +0200 Subject: [PATCH] AudioServer: Avoid two heap allocations per mixing iteration. --- Servers/AudioServer/ASMixer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Servers/AudioServer/ASMixer.cpp b/Servers/AudioServer/ASMixer.cpp index 472d126cec6..81d3180016a 100644 --- a/Servers/AudioServer/ASMixer.cpp +++ b/Servers/AudioServer/ASMixer.cpp @@ -61,7 +61,7 @@ void ASMixer::mix() max_size = min(1023, max_size); - Vector mixed_buffer; + Vector mixed_buffer; mixed_buffer.resize(max_size); // Mix the buffers together into the output @@ -91,7 +91,8 @@ void ASMixer::mix() // max_size is 0 indexed, so add 1. const int output_buffer_byte_size = (max_size + 1) * 2 * 2; ASSERT(output_buffer_byte_size == 4096); - ByteBuffer buffer(ByteBuffer::create_uninitialized(output_buffer_byte_size)); + u8 raw_buffer[4096]; + auto buffer = ByteBuffer::wrap(raw_buffer, sizeof(raw_buffer)); BufferStream stream(buffer); for (int i = 0; i < mixed_buffer.size(); ++i) {