From f57fedec7f8878230fb77be1d91d7c056f7e6de4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 26 May 2019 21:28:51 -0700 Subject: Get rid of the COUNTOF macro --- OpenAL32/Include/alMain.h | 6 ------ OpenAL32/alEffect.cpp | 24 ++++++++++++++---------- OpenAL32/alState.cpp | 5 +++-- 3 files changed, 17 insertions(+), 18 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index a8c7f3cd..7019a6d4 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -33,12 +33,6 @@ #include "hrtf.h" -template -constexpr inline size_t countof(const T(&)[N]) noexcept -{ return N; } -#define COUNTOF countof - - #ifndef UNUSED #if defined(__cplusplus) #define UNUSED(x) diff --git a/OpenAL32/alEffect.cpp b/OpenAL32/alEffect.cpp index 36a09442..51474af0 100644 --- a/OpenAL32/alEffect.cpp +++ b/OpenAL32/alEffect.cpp @@ -320,11 +320,17 @@ START_API_FUNC { if(param == AL_EFFECT_TYPE) { - ALboolean isOk = (value == AL_EFFECT_NULL); - for(size_t i{0u};!isOk && i < countof(gEffectList);i++) + ALboolean isOk{value == AL_EFFECT_NULL}; + if(!isOk) { - if(value == gEffectList[i].val && !DisabledEffects[gEffectList[i].type]) - isOk = AL_TRUE; + for(const EffectList &effectitem : gEffectList) + { + if(value == effectitem.val && !DisabledEffects[effectitem.type]) + { + isOk = AL_TRUE; + break; + } + } } if(isOk) @@ -669,8 +675,6 @@ static const struct { void LoadReverbPreset(const char *name, ALeffect *effect) { - size_t i; - if(strcasecmp(name, "NONE") == 0) { InitEffectParams(effect, AL_EFFECT_NULL); @@ -684,15 +688,15 @@ void LoadReverbPreset(const char *name, ALeffect *effect) InitEffectParams(effect, AL_EFFECT_REVERB); else InitEffectParams(effect, AL_EFFECT_NULL); - for(i = 0;i < COUNTOF(reverblist);i++) + for(const auto &reverbitem : reverblist) { const EFXEAXREVERBPROPERTIES *props; - if(strcasecmp(name, reverblist[i].name) != 0) + if(strcasecmp(name, reverbitem.name) != 0) continue; - TRACE("Loading reverb '%s'\n", reverblist[i].name); - props = &reverblist[i].props; + TRACE("Loading reverb '%s'\n", reverbitem.name); + props = &reverbitem.props; effect->Props.Reverb.Density = props->flDensity; effect->Props.Reverb.Diffusion = props->flDiffusion; effect->Props.Reverb.Gain = props->flGain; diff --git a/OpenAL32/alState.cpp b/OpenAL32/alState.cpp index 3f6a0388..0c447645 100644 --- a/OpenAL32/alState.cpp +++ b/OpenAL32/alState.cpp @@ -30,6 +30,7 @@ #include "alu.h" #include "alError.h" #include "alexcpt.h" +#include "alspan.h" #include "backends/base.h" @@ -788,7 +789,7 @@ START_API_FUNC alCubicResampler, alBSinc12Resampler, alBSinc24Resampler, }; - static_assert(COUNTOF(ResamplerNames) == ResamplerMax+1, "Incorrect ResamplerNames list"); + static_assert(al::size(ResamplerNames) == ResamplerMax+1, "Incorrect ResamplerNames list"); ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return nullptr; @@ -797,7 +798,7 @@ START_API_FUNC switch(pname) { case AL_RESAMPLER_NAME_SOFT: - if(index < 0 || static_cast(index) >= COUNTOF(ResamplerNames)) + if(index < 0 || static_cast(index) >= al::size(ResamplerNames)) alSetError(context.get(), AL_INVALID_VALUE, "Resampler name index %d out of range", index); else -- cgit v1.2.3