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

Side by Side Diff: components/url_matcher/regex_set_matcher.cc

Issue 2443753003: Remove stl_util's deletion function use from components/url_matcher/. (Closed)
Patch Set: Created 4 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/url_matcher/regex_set_matcher.h" 5 #include "components/url_matcher/regex_set_matcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "components/url_matcher/substring_set_matcher.h" 12 #include "components/url_matcher/substring_set_matcher.h"
13 #include "third_party/re2/src/re2/filtered_re2.h" 13 #include "third_party/re2/src/re2/filtered_re2.h"
14 #include "third_party/re2/src/re2/re2.h" 14 #include "third_party/re2/src/re2/re2.h"
15 15
16 namespace url_matcher { 16 namespace url_matcher {
17 17
18 RegexSetMatcher::RegexSetMatcher() {} 18 RegexSetMatcher::RegexSetMatcher() {}
19 19
20 RegexSetMatcher::~RegexSetMatcher() { 20 RegexSetMatcher::~RegexSetMatcher() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 std::vector<std::string> strings_to_match; 96 std::vector<std::string> strings_to_match;
97 filtered_re2_->Compile(&strings_to_match); 97 filtered_re2_->Compile(&strings_to_match);
98 98
99 substring_matcher_.reset(new SubstringSetMatcher); 99 substring_matcher_.reset(new SubstringSetMatcher);
100 DeleteSubstringPatterns(); 100 DeleteSubstringPatterns();
101 // Build SubstringSetMatcher from |strings_to_match|. 101 // Build SubstringSetMatcher from |strings_to_match|.
102 // SubstringSetMatcher doesn't own its strings. 102 // SubstringSetMatcher doesn't own its strings.
103 for (size_t i = 0; i < strings_to_match.size(); ++i) { 103 for (size_t i = 0; i < strings_to_match.size(); ++i) {
104 substring_patterns_.push_back( 104 substring_patterns_.push_back(
105 new StringPattern(strings_to_match[i], i)); 105 base::MakeUnique<StringPattern>(strings_to_match[i], i));
106 } 106 }
107 substring_matcher_->RegisterPatterns(substring_patterns_); 107 std::vector<const StringPattern*> patterns;
108 for (const auto& pattern : substring_patterns_)
109 patterns.push_back(pattern.get());
110 substring_matcher_->RegisterPatterns(patterns);
108 } 111 }
109 112
110 void RegexSetMatcher::DeleteSubstringPatterns() { 113 void RegexSetMatcher::DeleteSubstringPatterns() {
battre 2016/10/24 11:32:16 I think here should go call to substring_patterns_
Avi (use Gerrit) 2016/10/24 14:38:06 Agreed. I missed that this wasn't a destructor.
111 base::STLDeleteElements(&substring_patterns_);
112 } 114 }
113 115
114 } // namespace url_matcher 116 } // namespace url_matcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698