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

Side by Side Diff: extensions/common/url_pattern_set.cc

Issue 255903002: Use base::STLSet* in place of std::set_* for simplicity and consistency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/url_pattern_set.h" 5 #include "extensions/common/url_pattern_set.h"
6 6
7 #include <algorithm>
8 #include <iterator> 7 #include <iterator>
9 8
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
12 #include "base/stl_util.h" 11 #include "base/stl_util.h"
13 #include "base/values.h" 12 #include "base/values.h"
14 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
15 #include "extensions/common/error_utils.h" 14 #include "extensions/common/error_utils.h"
16 #include "extensions/common/url_pattern.h" 15 #include "extensions/common/url_pattern.h"
17 #include "url/gurl.h" 16 #include "url/gurl.h"
(...skipping 13 matching lines...) Expand all
31 out->ClearPatterns(); 30 out->ClearPatterns();
32 out->patterns_ = base::STLSetDifference<std::set<URLPattern> >( 31 out->patterns_ = base::STLSetDifference<std::set<URLPattern> >(
33 set1.patterns_, set2.patterns_); 32 set1.patterns_, set2.patterns_);
34 } 33 }
35 34
36 // static 35 // static
37 void URLPatternSet::CreateIntersection(const URLPatternSet& set1, 36 void URLPatternSet::CreateIntersection(const URLPatternSet& set1,
38 const URLPatternSet& set2, 37 const URLPatternSet& set2,
39 URLPatternSet* out) { 38 URLPatternSet* out) {
40 out->ClearPatterns(); 39 out->ClearPatterns();
41 std::set_intersection(set1.patterns_.begin(), set1.patterns_.end(), 40 out->patterns_ = base::STLSetIntersection<std::set<URLPattern> >(
Jeffrey Yasskin 2014/04/25 15:14:23 Since you're reassigning patterns_ instead of appe
Sungmann Cho 2014/04/25 15:39:24 Done.
42 set2.patterns_.begin(), set2.patterns_.end(), 41 set1.patterns_, set2.patterns_);
43 std::inserter<std::set<URLPattern> >(
44 out->patterns_, out->patterns_.begin()));
45 } 42 }
46 43
47 // static 44 // static
48 void URLPatternSet::CreateUnion(const URLPatternSet& set1, 45 void URLPatternSet::CreateUnion(const URLPatternSet& set1,
49 const URLPatternSet& set2, 46 const URLPatternSet& set2,
50 URLPatternSet* out) { 47 URLPatternSet* out) {
51 out->ClearPatterns(); 48 out->ClearPatterns();
52 std::set_union(set1.patterns_.begin(), set1.patterns_.end(), 49 out->patterns_ = base::STLSetUnion<std::set<URLPattern> >(
53 set2.patterns_.begin(), set2.patterns_.end(), 50 set1.patterns_, set2.patterns_);
54 std::inserter<std::set<URLPattern> >(
55 out->patterns_, out->patterns_.begin()));
56 } 51 }
57 52
58 // static 53 // static
59 void URLPatternSet::CreateUnion(const std::vector<URLPatternSet>& sets, 54 void URLPatternSet::CreateUnion(const std::vector<URLPatternSet>& sets,
60 URLPatternSet* out) { 55 URLPatternSet* out) {
61 out->ClearPatterns(); 56 out->ClearPatterns();
62 if (sets.empty()) 57 if (sets.empty())
63 return; 58 return;
64 59
65 // N-way union algorithm is basic O(nlog(n)) merge algorithm. 60 // N-way union algorithm is basic O(nlog(n)) merge algorithm.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 for (size_t i = 0; i < value.GetSize(); ++i) { 218 for (size_t i = 0; i < value.GetSize(); ++i) {
224 std::string item; 219 std::string item;
225 if (!value.GetString(i, &item)) 220 if (!value.GetString(i, &item))
226 return false; 221 return false;
227 patterns.push_back(item); 222 patterns.push_back(item);
228 } 223 }
229 return Populate(patterns, valid_schemes, allow_file_access, error); 224 return Populate(patterns, valid_schemes, allow_file_access, error);
230 } 225 }
231 226
232 } // namespace extensions 227 } // namespace extensions
OLDNEW
« 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