diff options
author | Chris Robinson <[email protected]> | 2019-09-12 17:10:33 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-12 17:10:33 -0700 |
commit | 5ca8796d6ab804841be2724ecb3daa134eb23c39 (patch) | |
tree | aee811068a738ce9f42b690df898b66eaf4623b5 /al/filter.cpp | |
parent | 70b58d79fe06581a7ca6db3feb17d5d07f8f8de6 (diff) |
Clean up some lambda definitions
Diffstat (limited to 'al/filter.cpp')
-rw-r--r-- | al/filter.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/al/filter.cpp b/al/filter.cpp index 2dd82bb0..33887254 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -312,7 +312,6 @@ ALfilter *AllocFilter(ALCdevice *device) [](const FilterSubList &entry) noexcept -> bool { return entry.FreeMask != 0; } ); - auto lidx = static_cast<ALuint>(std::distance(device->FilterList.begin(), sublist)); auto slidx = static_cast<ALuint>(CTZ64(sublist->FreeMask)); @@ -408,31 +407,24 @@ START_API_FUNC std::lock_guard<std::mutex> _{device->FilterLock}; /* First try to find any filters that are invalid. */ + auto validate_filter = [device](const ALuint fid) -> bool + { return !fid || LookupFilter(device, fid) != nullptr; }; + const ALuint *filters_end = filters + n; - auto invflt = std::find_if(filters, filters_end, - [device, &context](ALuint fid) -> bool - { - if(!fid) return false; - ALfilter *filter{LookupFilter(device, fid)}; - if UNLIKELY(!filter) - { - context->setError(AL_INVALID_NAME, "Invalid filter ID %u", fid); - return true; - } - return false; - } - ); - if LIKELY(invflt == filters_end) + auto invflt = std::find_if_not(filters, filters_end, validate_filter); + if UNLIKELY(invflt != filters_end) { - /* All good. Delete non-0 filter IDs. */ - std::for_each(filters, filters_end, - [device](ALuint fid) -> void - { - ALfilter *filter{fid ? LookupFilter(device, fid) : nullptr}; - if(filter) FreeFilter(device, filter); - } - ); + context->setError(AL_INVALID_NAME, "Invalid filter ID %u", *invflt); + return; } + + /* All good. Delete non-0 filter IDs. */ + auto delete_filter = [device](const ALuint fid) -> void + { + ALfilter *filter{fid ? LookupFilter(device, fid) : nullptr}; + if(filter) FreeFilter(device, filter); + }; + std::for_each(filters, filters_end, delete_filter); } END_API_FUNC |