From 36439bf906d24049c6dee02abc3cdee8fc3f1bf9 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Thu, 5 Sep 2013 06:02:56 +0000 Subject: [PATCH] NetEq4: Small change to reduce allocs in AudioMultiVector This change reduced the allocation count by 20000 in the bit-exactness test. BUG=Issue 1363 TEST=out/Debug/modules_unittests --gtest_filter=NetEqDecodingTest.TestBitExactness R=turaj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2157004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4678 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/audio_coding/neteq4/audio_multi_vector.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webrtc/modules/audio_coding/neteq4/audio_multi_vector.cc b/webrtc/modules/audio_coding/neteq4/audio_multi_vector.cc index 53fd1f4d24..7eb2142782 100644 --- a/webrtc/modules/audio_coding/neteq4/audio_multi_vector.cc +++ b/webrtc/modules/audio_coding/neteq4/audio_multi_vector.cc @@ -73,6 +73,11 @@ template void AudioMultiVector::PushBackInterleaved(const T* append_this, size_t length) { assert(length % Channels() == 0); + if (Channels() == 1) { + // Special case to avoid extra allocation and data shuffling. + channels_[0]->PushBack(append_this, length); + return; + } size_t length_per_channel = length / Channels(); T* temp_array = new T[length_per_channel]; // Intermediate storage. for (size_t channel = 0; channel < Channels(); ++channel) {