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/webrtc@4678 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/audio_coding/neteq4/audio_multi_vector.cc b/modules/audio_coding/neteq4/audio_multi_vector.cc
index 53fd1f4..7eb2142 100644
--- a/modules/audio_coding/neteq4/audio_multi_vector.cc
+++ b/modules/audio_coding/neteq4/audio_multi_vector.cc
@@ -73,6 +73,11 @@
void AudioMultiVector<T>::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) {