diff options
author | Chris Robinson <[email protected]> | 2022-01-22 23:18:19 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-01-22 23:18:19 -0800 |
commit | 3a02ba32e8a708069373823ed301a037987ed87d (patch) | |
tree | 40a8b5da3d513d7bbf3fb84fd15f3ea01ce2b639 /alc/backends/pipewire.cpp | |
parent | 5d6a2d0433f96d0ba947eade1c7d7eb6fe84df52 (diff) |
Avoid a messy while loop to remove from a vector
Diffstat (limited to 'alc/backends/pipewire.cpp')
-rw-r--r-- | alc/backends/pipewire.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 120e3af6..41949a9b 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -1104,18 +1104,15 @@ void EventManager::removeCallback(uint32_t id) { DeviceNode::Remove(id); - auto elem = mNodeList.begin(); - while(elem != mNodeList.end()) + auto clear_node = [id](NodeProxy *node) noexcept { - NodeProxy *node{*elem}; - if(node->mId == id) - { - al::destroy_at(node); - elem = mNodeList.erase(elem); - continue; - } - ++elem; - } + if(node->mId != id) + return false; + al::destroy_at(node); + return true; + }; + auto node_end = std::remove_if(mNodeList.begin(), mNodeList.end(), clear_node); + mNodeList.erase(node_end, mNodeList.end()); if(mDefaultMetadata && mDefaultMetadata->mId == id) { |