From 38b1030052a5e3d858fcff4385aa2e8013f59bc6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 24 Dec 2022 16:18:18 -0800 Subject: Avoid a manual loop to find a buffer queue entry --- al/source.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'al/source.cpp') diff --git a/al/source.cpp b/al/source.cpp index 5a16bba1..1ebacf5e 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -2546,12 +2546,9 @@ void StartSources(ALCcontext *const context, const al::span srchandle /* Check that there is a queue containing at least one valid, non zero * length buffer. */ - auto BufferList = source->mQueue.begin(); - for(;BufferList != source->mQueue.end();++BufferList) - { - if(BufferList->mSampleLen != 0 || BufferList->mCallback) - break; - } + auto find_buffer = [](ALbufferQueueItem &entry) noexcept + { return entry.mSampleLen != 0 || entry.mCallback != nullptr; }; + auto BufferList = std::find_if(source->mQueue.begin(), source->mQueue.end(), find_buffer); /* If there's nothing to play, go right to stopped. */ if(BufferList == source->mQueue.end()) [[unlikely]] -- cgit v1.2.3