Avoid unneccesry std::free in AudioSampleBuffer


#1

I use pre-allocated space, for backup-buffers in my audio-callback, and i create AudioSampleBuffers-Wrappers via setDataToReferTo, there is a call to allocatedData.free, i would be cool if you could add this check, to avoid a unnecessary call to std:free (It may sounds unimportant, but its a black-box, even when calling it with a nullptr, and i want to avoid any possible performance intrusion)

void AudioSampleBuffer::setDataToReferTo (float** dataToReferTo,

                                          const int newNumChannels,
                                          const int newNumSamples) noexcept
{
    jassert (dataToReferTo != nullptr);
    jassert (newNumChannels >= 0 && newNumSamples >= 0);
    if (allocatedBytes!=0) // <--
    {
        allocatedBytes = 0;
        allocatedData.free();
    };

 

 


#2

bump


#3

Already did this!


#4

ah okay, but not checked in yet it seems


#5

Oh yes, sorry, though I had pushed it. It's there now.