1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-18 17:47:41 +02:00

Rewrite Sequence::FindBlock using size_t variables for indices

This commit is contained in:
Paul Licameli 2016-08-20 20:58:13 -04:00
parent 49e699b1df
commit a1d930322c

View File

@ -1051,16 +1051,15 @@ int Sequence::FindBlock(sampleCount pos) const
int numBlocks = mBlock.size();
sampleCount lo = 0, loSamples = 0;
sampleCount hi = numBlocks, hiSamples = mNumSamples;
sampleCount guess;
size_t lo = 0, hi = numBlocks, guess;
sampleCount loSamples = 0, hiSamples = mNumSamples;
while (true) {
//this is not a binary search, but a
//dictionary search where we guess something smarter than the binary division
//of the unsearched area, since samples are usually proportional to block file number.
const double frac = double(pos - loSamples) / (hiSamples - loSamples);
guess = std::min(hi - 1, lo + sampleCount(frac * (hi - lo)));
guess = std::min(hi - 1, lo + size_t(frac * (hi - lo)));
const SeqBlock &block = mBlock[guess];
wxASSERT(block.f->GetLength() > 0);