diff options
author | Chris Robinson <[email protected]> | 2018-11-28 11:30:44 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-28 11:30:44 -0800 |
commit | ed2e456dfb6b0c11466a579142499767f7c80b73 (patch) | |
tree | 95ee776edf99f8c14049dfb5f28ecb73d1843f6a /Alc | |
parent | 8d95b6a0f2cb9c2cbbe745e37ff1ba2589d6aa17 (diff) |
Avoid some explicit loops
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index a0f61c8d..9956adc0 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -34,6 +34,7 @@ #include <thread> #include <vector> #include <string> +#include <numeric> #include <algorithm> #include "alMain.h" @@ -2388,21 +2389,24 @@ ALCdevice_struct::~ALCdevice_struct() DELETE_OBJ(Backend); Backend = nullptr; - size_t count{0u}; - for(auto &sublist : BufferList) - count += POPCNT64(~sublist.FreeMask); + size_t count{std::accumulate(BufferList.cbegin(), BufferList.cend(), size_t{0u}, + [](size_t cur, const BufferSubList &sublist) noexcept -> size_t + { return cur + POPCNT64(~sublist.FreeMask); } + )}; if(count > 0) WARN(SZFMT " Buffer%s not deleted\n", count, (count==1)?"":"s"); - count = 0; - for(auto &sublist : EffectList) - count += POPCNT64(~sublist.FreeMask); + count = std::accumulate(EffectList.cbegin(), EffectList.cend(), size_t{0u}, + [](size_t cur, const EffectSubList &sublist) noexcept -> size_t + { return cur + POPCNT64(~sublist.FreeMask); } + ); if(count > 0) WARN(SZFMT " Effect%s not deleted\n", count, (count==1)?"":"s"); - count = 0; - for(auto &sublist : FilterList) - count += POPCNT64(~sublist.FreeMask); + count = std::accumulate(FilterList.cbegin(), FilterList.cend(), size_t{0u}, + [](size_t cur, const FilterSubList &sublist) noexcept -> size_t + { return cur + POPCNT64(~sublist.FreeMask); } + ); if(count > 0) WARN(SZFMT " Filter%s not deleted\n", count, (count==1)?"":"s"); @@ -2575,9 +2579,10 @@ ALCcontext_struct::~ALCcontext_struct() } TRACE("Freed " SZFMT " context property object%s\n", count, (count==1)?"":"s"); - count = 0; - for(auto &sublist : SourceList) - count += POPCNT64(~sublist.FreeMask); + count = std::accumulate(SourceList.cbegin(), SourceList.cend(), size_t{0u}, + [](size_t cur, const SourceSubList &sublist) noexcept -> size_t + { return cur + POPCNT64(~sublist.FreeMask); } + ); if(count > 0) WARN(SZFMT " Source%s not deleted\n", count, (count==1)?"":"s"); SourceList.clear(); |