aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-09-03 14:53:46 -0700
committerChris Robinson <[email protected]>2015-09-03 14:53:46 -0700
commit23729c2083db494780606f1fd3223efdb451cf6e (patch)
treeaf8285e5dfcbc54bb40ddcb0fcfa9857b5b885a4 /Alc/backends
parent87e4ec66204ae9c241602589b907f213def8d879 (diff)
Replace another vector loop with VECTOR_FIND_IF
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/mmdevapi.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index b965e1ad..c5ac8512 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -674,7 +674,7 @@ static ALCenum ALCmmdevPlayback_open(ALCmmdevPlayback *self, const ALCchar *devi
{
if(deviceName)
{
- const DevMap *iter, *end;
+ const DevMap *iter;
if(VECTOR_SIZE(PlaybackDevices) == 0)
{
@@ -684,21 +684,18 @@ static ALCenum ALCmmdevPlayback_open(ALCmmdevPlayback *self, const ALCchar *devi
}
hr = E_FAIL;
- iter = VECTOR_ITER_BEGIN(PlaybackDevices);
- end = VECTOR_ITER_END(PlaybackDevices);
- for(;iter != end;iter++)
+#define MATCH_NAME(i) (al_string_cmp_cstr((i)->name, deviceName) == 0)
+ VECTOR_FIND_IF(iter, const DevMap, PlaybackDevices, MATCH_NAME);
+ if(iter == VECTOR_ITER_END(PlaybackDevices))
+ WARN("Failed to find device name matching \"%s\"\n", deviceName);
+ else
{
- if(al_string_cmp_cstr(iter->name, deviceName) == 0)
- {
- ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
- self->devid = strdupW(iter->devid);
- al_string_copy(&device->DeviceName, iter->name);
- hr = S_OK;
- break;
- }
+ ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
+ self->devid = strdupW(iter->devid);
+ al_string_copy(&device->DeviceName, iter->name);
+ hr = S_OK;
}
- if(FAILED(hr))
- WARN("Failed to find device name matching \"%s\"\n", deviceName);
+#undef MATCH_NAME
}
}