aboutsummaryrefslogtreecommitdiffstats
path: root/al/buffer.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-12 17:10:33 -0700
committerChris Robinson <[email protected]>2019-09-12 17:10:33 -0700
commit5ca8796d6ab804841be2724ecb3daa134eb23c39 (patch)
treeaee811068a738ce9f42b690df898b66eaf4623b5 /al/buffer.cpp
parent70b58d79fe06581a7ca6db3feb17d5d07f8f8de6 (diff)
Clean up some lambda definitions
Diffstat (limited to 'al/buffer.cpp')
-rw-r--r--al/buffer.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index de1b1e9a..42db68a8 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -682,36 +682,33 @@ START_API_FUNC
std::lock_guard<std::mutex> _{device->BufferLock};
/* First try to find any buffers that are invalid or in-use. */
- const ALuint *buffers_end = buffers + n;
- auto invbuf = std::find_if(buffers, buffers_end,
- [device, &context](ALuint bid) -> bool
+ auto validate_buffer = [device, &context](const ALuint bid) -> bool
+ {
+ if(!bid) return true;
+ ALbuffer *ALBuf{LookupBuffer(device, bid)};
+ if UNLIKELY(!ALBuf)
{
- if(!bid) return false;
- ALbuffer *ALBuf = LookupBuffer(device, bid);
- if UNLIKELY(!ALBuf)
- {
- context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", bid);
- return true;
- }
- if UNLIKELY(ReadRef(ALBuf->ref) != 0)
- {
- context->setError(AL_INVALID_OPERATION, "Deleting in-use buffer %u", bid);
- return true;
- }
+ context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", bid);
return false;
}
- );
- if LIKELY(invbuf == buffers_end)
+ if UNLIKELY(ReadRef(ALBuf->ref) != 0)
+ {
+ context->setError(AL_INVALID_OPERATION, "Deleting in-use buffer %u", bid);
+ return false;
+ }
+ return true;
+ };
+ const ALuint *buffers_end = buffers + n;
+ auto invbuf = std::find_if_not(buffers, buffers_end, validate_buffer);
+ if UNLIKELY(invbuf != buffers_end) return;
+
+ /* All good. Delete non-0 buffer IDs. */
+ auto delete_buffer = [device](const ALuint bid) -> void
{
- /* All good. Delete non-0 buffer IDs. */
- std::for_each(buffers, buffers_end,
- [device](ALuint bid) -> void
- {
- ALbuffer *buffer{bid ? LookupBuffer(device, bid) : nullptr};
- if(buffer) FreeBuffer(device, buffer);
- }
- );
- }
+ ALbuffer *buffer{bid ? LookupBuffer(device, bid) : nullptr};
+ if(buffer) FreeBuffer(device, buffer);
+ };
+ std::for_each(buffers, buffers_end, delete_buffer);
}
END_API_FUNC