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 <ivoc@webrtc.org>
Commit-Queue: Christian Schuldt <cschuldt@google.com>
Cr-Commit-Position: refs/heads/main@{#35478}
This commit is contained in:
cschuldt 2021-12-03 15:20:56 +01:00 committed by WebRTC LUCI CQ
parent 2394977f74
commit 4647528911

View File

@ -27,8 +27,8 @@ namespace {
enum class EchoCanceller3ApiCall { kCapture, kRender };
bool DetectSaturation(rtc::ArrayView<const float> 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;
}
}