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

Side by Side Diff: extensions/common/matcher/url_matcher.cc

Issue 22460011: [CleanUp] Use base::STLSetDifference in place of std::set_difference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing head file. Created 7 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/common/matcher/url_matcher.h" 5 #include "extensions/common/matcher/url_matcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 745 }
746 } 746 }
747 747
748 // This is the set of patterns that were registered before this function 748 // This is the set of patterns that were registered before this function
749 // is called. 749 // is called.
750 std::set<const StringPattern*>& registered_patterns = 750 std::set<const StringPattern*>& registered_patterns =
751 full_url_conditions ? registered_full_url_patterns_ 751 full_url_conditions ? registered_full_url_patterns_
752 : registered_url_component_patterns_; 752 : registered_url_component_patterns_;
753 753
754 // Add all patterns that are in new_patterns but not in registered_patterns. 754 // Add all patterns that are in new_patterns but not in registered_patterns.
755 std::vector<const StringPattern*> patterns_to_register; 755 std::vector<const StringPattern*> patterns_to_register =
756 std::set_difference( 756 base::STLSetDifference<std::vector<const StringPattern*> >(
757 new_patterns.begin(), new_patterns.end(), 757 new_patterns, registered_patterns);
758 registered_patterns.begin(), registered_patterns.end(),
759 std::back_inserter(patterns_to_register));
760 758
761 // Remove all patterns that are in registered_patterns but not in 759 // Remove all patterns that are in registered_patterns but not in
762 // new_patterns. 760 // new_patterns.
763 std::vector<const StringPattern*> patterns_to_unregister; 761 std::vector<const StringPattern*> patterns_to_unregister =
764 std::set_difference( 762 base::STLSetDifference<std::vector<const StringPattern*> >(
765 registered_patterns.begin(), registered_patterns.end(), 763 registered_patterns, new_patterns);
766 new_patterns.begin(), new_patterns.end(),
767 std::back_inserter(patterns_to_unregister));
768 764
769 // Update the SubstringSetMatcher. 765 // Update the SubstringSetMatcher.
770 SubstringSetMatcher& url_matcher = 766 SubstringSetMatcher& url_matcher =
771 full_url_conditions ? full_url_matcher_ : url_component_matcher_; 767 full_url_conditions ? full_url_matcher_ : url_component_matcher_;
772 url_matcher.RegisterAndUnregisterPatterns(patterns_to_register, 768 url_matcher.RegisterAndUnregisterPatterns(patterns_to_register,
773 patterns_to_unregister); 769 patterns_to_unregister);
774 770
775 // Update the set of registered_patterns for the next time this function 771 // Update the set of registered_patterns for the next time this function
776 // is being called. 772 // is being called.
777 registered_patterns.swap(new_patterns); 773 registered_patterns.swap(new_patterns);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 872
877 void URLMatcher::UpdateInternalDatastructures() { 873 void URLMatcher::UpdateInternalDatastructures() {
878 UpdateSubstringSetMatcher(false); 874 UpdateSubstringSetMatcher(false);
879 UpdateSubstringSetMatcher(true); 875 UpdateSubstringSetMatcher(true);
880 UpdateRegexSetMatcher(); 876 UpdateRegexSetMatcher();
881 UpdateTriggers(); 877 UpdateTriggers();
882 UpdateConditionFactory(); 878 UpdateConditionFactory();
883 } 879 }
884 880
885 } // namespace extensions 881 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permission_set.cc ('k') | ui/base/test/ui_cocoa_test_helper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698