AEC3: Avoid heap-allocations in sums of the values in nested vectors
This CL avoids the head-allocations done in a sum of the squared values
in a nested vector.
Bug: webrtc:11361, chromium:1052086
Change-Id: I698b855bdd54df2147ef3b6d5e3d401401228d76
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168543
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30520}
diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc
index ea7af50..c1f12b7 100644
--- a/modules/audio_processing/aec3/suppression_gain.cc
+++ b/modules/audio_processing/aec3/suppression_gain.cc
@@ -390,8 +390,8 @@
const std::vector<std::vector<std::vector<float>>>& render) {
float x2_sum = 0.f;
float x2_max = 0.f;
- for (auto x_ch : render[0]) {
- for (auto x_k : x_ch) {
+ for (const auto& x_ch : render[0]) {
+ for (const auto& x_k : x_ch) {
const float x2 = x_k * x_k;
x2_sum += x2;
x2_max = std::max(x2_max, x2);