diff options
author | Chris Robinson <[email protected]> | 2023-10-20 09:35:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-10-20 09:35:16 -0700 |
commit | 956af2513a079d3e1eac60c1bc02aa0e69630152 (patch) | |
tree | 63b8c008c9c2011ca8293161406c47f9c2bff1f4 | |
parent | f15749e7dadbb2d6050c037da9ccd97e8f4dc31c (diff) |
Don't keep setting and reloading a struct member in a loop
-rw-r--r-- | core/uhjfilter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/uhjfilter.cpp b/core/uhjfilter.cpp index a8b75494..dfd11b37 100644 --- a/core/uhjfilter.cpp +++ b/core/uhjfilter.cpp @@ -232,6 +232,7 @@ void UhjEncoder<N>::encode(float *LeftOut, float *RightOut, mS[i] = 0.9396926f*mW[i] + 0.1855740f*mX[i]; /* Precompute j(-0.3420201*W + 0.5098604*X) and store in mD. */ + size_t curseg{mCurrentSegment}; for(size_t base{0};base < SamplesToDo;) { const size_t todo{minz(sSegmentSize-mFifoPos, SamplesToDo-base)}; @@ -266,7 +267,6 @@ void UhjEncoder<N>::encode(float *LeftOut, float *RightOut, std::fill(mWXIn.begin()+sSegmentSize, mWXIn.end(), 0.0f); /* Overwrite the stale/oldest FFT'd segment with the newest input. */ - const size_t curseg{mCurrentSegment}; pffft_transform(Filter.mFft.get(), mWXIn.data(), mWXHistory.data() + curseg*sFftLength, mWorkData.data(), PFFFT_FORWARD); @@ -302,8 +302,9 @@ void UhjEncoder<N>::encode(float *LeftOut, float *RightOut, mWXOut[sSegmentSize+i] = mFftBuffer[sSegmentSize+i]; /* Shift the input history. */ - mCurrentSegment = curseg ? (curseg-1) : (sNumSegments-1); + curseg = curseg ? (curseg-1) : (sNumSegments-1); } + mCurrentSegment = curseg; /* D = j(-0.3420201*W + 0.5098604*X) + 0.6554516*Y */ for(size_t i{0};i < SamplesToDo;++i) |