summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-03-08 09:13:16 (GMT)
committerKevin Smith <kevin.smith@isode.com>2017-03-08 11:31:21 (GMT)
commita7ea0a4f7899ce7365cdc293089641ac2b39dfb8 (patch)
treed49237e6e090825816c20f0593f0bb968d84804d
parent121361e37bc2cc8ab1eae2f2aea92975a62e5511 (diff)
downloadswift-a7ea0a4f7899ce7365cdc293089641ac2b39dfb8.zip
swift-a7ea0a4f7899ce7365cdc293089641ac2b39dfb8.tar.bz2
Use standard algorithm instead of custom code
Test-Information: Builds on macOS 10.12.3 and unit tests pass. Roster filtering still works and does not crash in an ASAN-enabled build. Change-Id: I545a582b003cd0c15dff43b73b0922dcbf4055af
-rw-r--r--Swift/Controllers/Roster/Roster.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp
index 68297a4..9c9b9e3 100644
--- a/Swift/Controllers/Roster/Roster.cpp
+++ b/Swift/Controllers/Roster/Roster.cpp
@@ -6,6 +6,7 @@
#include <Swift/Controllers/Roster/Roster.h>
+#include <algorithm>
#include <deque>
#include <memory>
#include <set>
@@ -222,12 +223,7 @@ void Roster::addFilter(RosterFilter* filter) {
}
void Roster::removeFilter(RosterFilter* filter) {
- for (unsigned int i = 0; i < filters_.size(); i++) {
- if (filters_[i] == filter) {
- filters_.erase(filters_.begin() + i);
- break;
- }
- }
+ filters_.erase(std::remove(filters_.begin(), filters_.end(), filter), filters_.end());
filterAll();
onFilterRemoved(filter);
}