aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-22 22:53:22 -0800
committerChris Robinson <[email protected]>2018-11-22 22:53:22 -0800
commit438e626993fe86831b666a42b5f90731d5c26aeb (patch)
tree9fb4dc49e8dc1d5bc43a7f4e8c3986db4ec4f972 /Alc
parent976e49711b47d6c742995986e976275badb5c9f0 (diff)
Avoid a couple explicit loops
Diffstat (limited to 'Alc')
-rw-r--r--Alc/panning.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index a67234ec..7b5a6674 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -219,32 +219,31 @@ static inline const char *GetLabelFromChannel(enum Channel channel)
}
-typedef struct ChannelMap {
- enum Channel ChanName;
+struct ChannelMap {
+ Channel ChanName;
ChannelConfig Config;
-} ChannelMap;
+};
-static void SetChannelMap(const enum Channel devchans[MAX_OUTPUT_CHANNELS],
+static void SetChannelMap(const Channel (&devchans)[MAX_OUTPUT_CHANNELS],
ChannelConfig *ambicoeffs, const ChannelMap *chanmap,
ALsizei count, ALsizei *outcount)
{
- ALsizei maxchans = 0;
- ALsizei i, j;
-
- for(i = 0;i < count;i++)
- {
- ALint idx = GetChannelIndex(devchans, chanmap[i].ChanName);
- if(idx < 0)
+ ALsizei maxchans{0};
+ std::for_each(chanmap, chanmap+count,
+ [&maxchans,&devchans,ambicoeffs](const ChannelMap &channel) -> void
{
- ERR("Failed to find %s channel in device\n",
- GetLabelFromChannel(chanmap[i].ChanName));
- continue;
- }
+ ALint idx = GetChannelIndex(devchans, channel.ChanName);
+ if(idx < 0)
+ {
+ ERR("Failed to find %s channel in device\n",
+ GetLabelFromChannel(channel.ChanName));
+ return;
+ }
- maxchans = maxi(maxchans, idx+1);
- for(j = 0;j < MAX_AMBI_COEFFS;j++)
- ambicoeffs[idx][j] = chanmap[i].Config[j];
- }
+ maxchans = maxi(maxchans, idx+1);
+ std::copy_n(channel.Config, MAX_AMBI_COEFFS, ambicoeffs[idx]);
+ }
+ );
*outcount = mini(maxchans, MAX_OUTPUT_CHANNELS);
}