diff options
author | Chris Robinson <[email protected]> | 2023-12-23 04:18:07 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-12-23 04:18:07 -0800 |
commit | cfb6bdfabfdf70ce5bcb650d356c3a9c1db3df0c (patch) | |
tree | 6776ebcdd9b5bac5812e97d580290e5ebd2676a7 /alc/alc.cpp | |
parent | 4720b2c64d91facea24e8411c104770bd3763afa (diff) |
Avoid assignments in if conditions
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r-- | alc/alc.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 3ad07aaa..d944cf0c 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -562,7 +562,8 @@ void alc_initconfig() auto BackendListEnd = std::end(BackendList); auto devopt = al::getenv("ALSOFT_DRIVERS"); - if(devopt || (devopt=ConfigValueStr({}, {}, "drivers"))) + if(!devopt) devopt = ConfigValueStr({}, {}, "drivers"); + if(devopt) { auto backendlist_cur = std::begin(BackendList); @@ -670,8 +671,8 @@ void alc_initconfig() InitEffect(&ALCcontext::sDefaultEffect); auto defrevopt = al::getenv("ALSOFT_DEFAULT_REVERB"); - if(defrevopt || (defrevopt=ConfigValueStr({}, {}, "default-reverb"))) - LoadReverbPreset(defrevopt->c_str(), &ALCcontext::sDefaultEffect); + if(!defrevopt) defrevopt = ConfigValueStr({}, {}, "default-reverb"); + if(defrevopt) LoadReverbPreset(defrevopt->c_str(), &ALCcontext::sDefaultEffect); #ifdef ALSOFT_EAX { @@ -2556,23 +2557,25 @@ ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const A { DeviceRef dev{VerifyDevice(device)}; if(!extName) + { alcSetError(dev.get(), ALC_INVALID_VALUE); - else + return ALC_FALSE; + } + + const std::string_view tofind{extName}; + auto extlist = dev ? std::string_view{alcExtensionList} : std::string_view{alcNoDeviceExtList}; + while(!extlist.empty()) { - size_t len = strlen(extName); - const char *ptr = (dev ? alcExtensionList : alcNoDeviceExtList); - while(ptr && *ptr) - { - if(al::strncasecmp(ptr, extName, len) == 0 && (ptr[len] == '\0' || isspace(ptr[len]))) - return ALC_TRUE; + auto nextpos = extlist.find(' '); + auto tocheck = extlist.substr(0, nextpos); + if(tocheck.size() == tofind.size() + && al::strncasecmp(tofind.data(), tocheck.data(), tofind.size()) == 0) + return ALC_TRUE; - if((ptr=strchr(ptr, ' ')) != nullptr) - { - do { - ++ptr; - } while(isspace(*ptr)); - } - } + if(nextpos == std::string_view::npos) + break; + + extlist.remove_prefix(nextpos+1); } return ALC_FALSE; } |