aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-12-24 16:18:18 -0800
committerChris Robinson <[email protected]>2022-12-24 16:18:18 -0800
commit38b1030052a5e3d858fcff4385aa2e8013f59bc6 (patch)
treedb797bf259ead4f8a2b594f8afbe7a6ee2a6b856 /al
parent5340e32484292e2f25b515e265c0f609f4d00233 (diff)
Avoid a manual loop to find a buffer queue entry
Diffstat (limited to 'al')
-rw-r--r--al/source.cpp9
1 files changed, 3 insertions, 6 deletions
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<ALsource*> 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]]