Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: base/observer_list.h

Issue 8391003: Change O(n^2) loop to O(n) in ObserverListBase::Compact(). (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/observer_list.h
===================================================================
--- base/observer_list.h (revision 107110)
+++ base/observer_list.h (working copy)
@@ -162,14 +162,9 @@
protected:
void Compact() {
- typename ListType::iterator it = observers_.begin();
- while (it != observers_.end()) {
- if (*it) {
- ++it;
- } else {
- it = observers_.erase(it);
- }
- }
+ observers_.erase(
+ std::remove(observers_.begin(), observers_.end(),
+ static_cast<ObserverType*>(NULL)), observers_.end());
}
private:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698