mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Avoid repeated FindBlock call in Sequence::Get when we can
This commit is contained in:
parent
dc599116f7
commit
dd3df60a83
@ -439,7 +439,7 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, Sequence **dest)
|
||||
BlockFile *const file = block0.f;
|
||||
blocklen = std::min(s1, block0.start + file->GetLength()) - s0;
|
||||
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
||||
Get(buffer.ptr(), mSampleFormat, s0, blocklen);
|
||||
Get(b0, buffer.ptr(), mSampleFormat, s0, blocklen);
|
||||
|
||||
(*dest)->Append(buffer.ptr(), mSampleFormat, blocklen);
|
||||
}
|
||||
@ -457,7 +457,7 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, Sequence **dest)
|
||||
blocklen = (s1 - block.start);
|
||||
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
|
||||
if (blocklen < file->GetLength()) {
|
||||
Get(buffer.ptr(), mSampleFormat, block.start, blocklen);
|
||||
Get(b1, buffer.ptr(), mSampleFormat, block.start, blocklen);
|
||||
(*dest)->Append(buffer.ptr(), mSampleFormat, blocklen);
|
||||
}
|
||||
else
|
||||
@ -548,7 +548,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
|
||||
int splitPoint = s - block.start;
|
||||
Read(buffer.ptr(), mSampleFormat, block, 0, splitPoint);
|
||||
src->Get(buffer.ptr() + splitPoint*sampleSize,
|
||||
src->Get(0, buffer.ptr() + splitPoint*sampleSize,
|
||||
mSampleFormat, 0, addedLen);
|
||||
Read(buffer.ptr() + (splitPoint + addedLen)*sampleSize,
|
||||
mSampleFormat, block,
|
||||
@ -587,7 +587,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
|
||||
SampleBuffer sumBuffer(sum, mSampleFormat);
|
||||
Read(sumBuffer.ptr(), mSampleFormat, splitBlock, 0, splitPoint);
|
||||
src->Get(sumBuffer.ptr() + splitPoint * sampleSize,
|
||||
src->Get(0, sumBuffer.ptr() + splitPoint * sampleSize,
|
||||
mSampleFormat,
|
||||
0, addedLen);
|
||||
Read(sumBuffer.ptr() + (splitPoint + addedLen) * sampleSize, mSampleFormat,
|
||||
@ -617,7 +617,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
SampleBuffer sampleBuffer(std::max(leftLen, rightLen), mSampleFormat);
|
||||
|
||||
Read(sampleBuffer.ptr(), mSampleFormat, splitBlock, 0, splitPoint);
|
||||
src->Get(sampleBuffer.ptr() + splitPoint*sampleSize,
|
||||
src->Get(0, sampleBuffer.ptr() + splitPoint*sampleSize,
|
||||
mSampleFormat, 0, srcFirstTwoLen);
|
||||
|
||||
Blockify(newBlock, splitBlock.start, sampleBuffer.ptr(), leftLen);
|
||||
@ -634,7 +634,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
}
|
||||
|
||||
sampleCount lastStart = penultimate.start;
|
||||
src->Get(sampleBuffer.ptr(), mSampleFormat,
|
||||
src->Get(srcNumBlocks - 2, sampleBuffer.ptr(), mSampleFormat,
|
||||
lastStart, srcLastTwoLen);
|
||||
Read(sampleBuffer.ptr() + srcLastTwoLen * sampleSize, mSampleFormat,
|
||||
splitBlock, splitPoint, rightSplit);
|
||||
@ -1173,6 +1173,12 @@ bool Sequence::Get(samplePtr buffer, sampleFormat format,
|
||||
return false;
|
||||
int b = FindBlock(start);
|
||||
|
||||
return Get(b, buffer, format, start, len);
|
||||
}
|
||||
|
||||
bool Sequence::Get(int b, samplePtr buffer, sampleFormat format,
|
||||
sampleCount start, sampleCount len) const
|
||||
{
|
||||
while (len) {
|
||||
const SeqBlock &block = mBlock.at(b);
|
||||
const sampleCount bstart = (start - (block.start));
|
||||
|
@ -252,6 +252,9 @@ class Sequence: public XMLTagHandler {
|
||||
|
||||
void Blockify(BlockArray &list, sampleCount start, samplePtr buffer, sampleCount len);
|
||||
|
||||
bool Get(int b, samplePtr buffer, sampleFormat format,
|
||||
sampleCount start, sampleCount len) const;
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user