From 464752891124c5109d85aa839acd935a089142f5 Mon Sep 17 00:00:00 2001 From: cschuldt Date: Fri, 3 Dec 2021 15:20:56 +0100 Subject: [PATCH] Optimize the saturation detection (used by AnalyzeCapture()). Changing to an index for-loop (instead of a range for-loop) allows the compiler (clang for x86 at least) to unroll it x2. Bug: None Change-Id: I9b9612a8513a06e8aa3b12ae39f6911217da55fa Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/239741 Reviewed-by: Ivo Creusen Commit-Queue: Christian Schuldt Cr-Commit-Position: refs/heads/main@{#35478} --- modules/audio_processing/aec3/echo_canceller3.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc index 6316a2bf48..58fb6a49a3 100644 --- a/modules/audio_processing/aec3/echo_canceller3.cc +++ b/modules/audio_processing/aec3/echo_canceller3.cc @@ -27,8 +27,8 @@ namespace { enum class EchoCanceller3ApiCall { kCapture, kRender }; bool DetectSaturation(rtc::ArrayView y) { - for (auto y_k : y) { - if (y_k >= 32700.0f || y_k <= -32700.0f) { + for (size_t k = 0; k < y.size(); ++k) { + if (y[k] >= 32700.0f || y[k] <= -32700.0f) { return true; } }