Further optimization of AudioVector::operator[]
This is a follow-up to https://codereview.webrtc.org/2670643007/. That CL provided significant improvement to Mac, Linux and ARM-based platforms, but failed to improve the performance for Windows. The problem is that the MSVC compiler did not produce branch-free code for that fix. This new change produces the same result for non-Windows platforms, as well as introduces branch-free code for Windows. H/t to kwiberg@ for providing the solution. BUG=webrtc:7159 Review-Url: https://codereview.webrtc.org/2700633003 Cr-Commit-Position: refs/heads/master@{#16649}
This commit is contained in:
parent
3ebabf1c29
commit
751589899b
@ -128,9 +128,8 @@ class AudioVector {
|
||||
size_t begin_index,
|
||||
size_t capacity) {
|
||||
RTC_DCHECK_GE(begin_index + index, index); // Check for overflow.
|
||||
const size_t ix = begin_index + index >= capacity
|
||||
? begin_index + index - capacity
|
||||
: begin_index + index;
|
||||
const size_t ix =
|
||||
begin_index + index - (begin_index + index >= capacity ? capacity : 0);
|
||||
RTC_DCHECK_LT(ix, capacity);
|
||||
return ix;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user