OLD | NEW |
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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "components/url_matcher/substring_set_matcher.h" | 10 #include "components/url_matcher/substring_set_matcher.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 size_t old_number_of_matches = matches->size(); | 40 size_t old_number_of_matches = matches->size(); |
41 if (regexes_.empty()) | 41 if (regexes_.empty()) |
42 return false; | 42 return false; |
43 if (!filtered_re2_.get()) { | 43 if (!filtered_re2_.get()) { |
44 LOG(ERROR) << "RegexSetMatcher was not initialized"; | 44 LOG(ERROR) << "RegexSetMatcher was not initialized"; |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 // FilteredRE2 expects lowercase for prefiltering, but we still | 48 // FilteredRE2 expects lowercase for prefiltering, but we still |
49 // match case-sensitively. | 49 // match case-sensitively. |
50 std::vector<RE2ID> atoms(FindSubstringMatches( | 50 std::vector<RE2ID> atoms(FindSubstringMatches(base::ToLowerASCII(text))); |
51 base::StringToLowerASCII(text))); | |
52 | 51 |
53 std::vector<RE2ID> re2_ids; | 52 std::vector<RE2ID> re2_ids; |
54 filtered_re2_->AllMatches(text, atoms, &re2_ids); | 53 filtered_re2_->AllMatches(text, atoms, &re2_ids); |
55 | 54 |
56 for (size_t i = 0; i < re2_ids.size(); ++i) { | 55 for (size_t i = 0; i < re2_ids.size(); ++i) { |
57 StringPattern::ID id = re2_id_map_[re2_ids[i]]; | 56 StringPattern::ID id = re2_id_map_[re2_ids[i]]; |
58 matches->insert(id); | 57 matches->insert(id); |
59 } | 58 } |
60 return old_number_of_matches != matches->size(); | 59 return old_number_of_matches != matches->size(); |
61 } | 60 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 new StringPattern(strings_to_match[i], i)); | 103 new StringPattern(strings_to_match[i], i)); |
105 } | 104 } |
106 substring_matcher_->RegisterPatterns(substring_patterns_); | 105 substring_matcher_->RegisterPatterns(substring_patterns_); |
107 } | 106 } |
108 | 107 |
109 void RegexSetMatcher::DeleteSubstringPatterns() { | 108 void RegexSetMatcher::DeleteSubstringPatterns() { |
110 STLDeleteElements(&substring_patterns_); | 109 STLDeleteElements(&substring_patterns_); |
111 } | 110 } |
112 | 111 |
113 } // namespace url_matcher | 112 } // namespace url_matcher |
OLD | NEW |