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

Unified Diff: components/url_matcher/substring_set_matcher.cc

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: components/url_matcher/substring_set_matcher.cc
diff --git a/components/url_matcher/substring_set_matcher.cc b/components/url_matcher/substring_set_matcher.cc
index 848c86300e8482da1afad5962fbedc5ced86129d..dff9aa732574378dcb375891d37c490b9aa864d3 100644
--- a/components/url_matcher/substring_set_matcher.cc
+++ b/components/url_matcher/substring_set_matcher.cc
@@ -4,6 +4,8 @@
#include "components/url_matcher/substring_set_matcher.h"
+#include <stddef.h>
+
#include <algorithm>
#include <queue>
@@ -21,8 +23,8 @@ bool ComparePatterns(const StringPattern* a, const StringPattern* b) {
// Given the set of patterns, compute how many nodes will the corresponding
// Aho-Corasick tree have. Note that |patterns| need to be sorted.
-uint32 TreeSize(const std::vector<const StringPattern*>& patterns) {
- uint32 result = 1u; // 1 for the root node.
+uint32_t TreeSize(const std::vector<const StringPattern*>& patterns) {
+ uint32_t result = 1u; // 1 for the root node.
if (patterns.empty())
return result;
@@ -37,10 +39,10 @@ uint32 TreeSize(const std::vector<const StringPattern*>& patterns) {
for (; current != patterns.end(); ++last, ++current) {
const std::string& last_pattern = (*last)->pattern();
const std::string& current_pattern = (*current)->pattern();
- const uint32 prefix_bound =
+ const uint32_t prefix_bound =
std::min(last_pattern.size(), current_pattern.size());
- uint32 common_prefix = 0;
+ uint32_t common_prefix = 0;
while (common_prefix < prefix_bound &&
last_pattern[common_prefix] == current_pattern[common_prefix])
++common_prefix;
@@ -113,9 +115,9 @@ bool SubstringSetMatcher::Match(const std::string& text,
// Handle patterns matching the empty string.
matches->insert(tree_[0].matches().begin(), tree_[0].matches().end());
- uint32 current_node = 0;
+ uint32_t current_node = 0;
for (std::string::const_iterator i = text.begin(); i != text.end(); ++i) {
- uint32 edge_from_current = tree_[current_node].GetEdge(*i);
+ uint32_t edge_from_current = tree_[current_node].GetEdge(*i);
while (edge_from_current == AhoCorasickNode::kNoSuchEdge &&
current_node != 0) {
current_node = tree_[current_node].failure();
@@ -163,12 +165,12 @@ void SubstringSetMatcher::InsertPatternIntoAhoCorasickTree(
const std::string::const_iterator text_end = text.end();
// Iterators on the tree and the text.
- uint32 current_node = 0;
+ uint32_t current_node = 0;
std::string::const_iterator i = text.begin();
// Follow existing paths for as long as possible.
while (i != text_end) {
- uint32 edge_from_current = tree_[current_node].GetEdge(*i);
+ uint32_t edge_from_current = tree_[current_node].GetEdge(*i);
if (edge_from_current == AhoCorasickNode::kNoSuchEdge)
break;
current_node = edge_from_current;
@@ -190,14 +192,14 @@ void SubstringSetMatcher::InsertPatternIntoAhoCorasickTree(
void SubstringSetMatcher::CreateFailureEdges() {
typedef AhoCorasickNode::Edges Edges;
- std::queue<uint32> queue;
+ std::queue<uint32_t> queue;
AhoCorasickNode& root = tree_[0];
root.set_failure(0);
const Edges& root_edges = root.edges();
for (Edges::const_iterator e = root_edges.begin(); e != root_edges.end();
++e) {
- const uint32& leads_to = e->second;
+ const uint32_t& leads_to = e->second;
tree_[leads_to].set_failure(0);
queue.push(leads_to);
}
@@ -208,28 +210,27 @@ void SubstringSetMatcher::CreateFailureEdges() {
for (Edges::const_iterator e = current_node.edges().begin();
e != current_node.edges().end(); ++e) {
const char& edge_label = e->first;
- const uint32& leads_to = e->second;
+ const uint32_t& leads_to = e->second;
queue.push(leads_to);
- uint32 failure = current_node.failure();
- uint32 edge_from_failure = tree_[failure].GetEdge(edge_label);
+ uint32_t failure = current_node.failure();
+ uint32_t edge_from_failure = tree_[failure].GetEdge(edge_label);
while (edge_from_failure == AhoCorasickNode::kNoSuchEdge &&
failure != 0) {
failure = tree_[failure].failure();
edge_from_failure = tree_[failure].GetEdge(edge_label);
}
- const uint32 follow_in_case_of_failure =
- edge_from_failure != AhoCorasickNode::kNoSuchEdge
- ? edge_from_failure
- : 0;
+ const uint32_t follow_in_case_of_failure =
+ edge_from_failure != AhoCorasickNode::kNoSuchEdge ? edge_from_failure
+ : 0;
tree_[leads_to].set_failure(follow_in_case_of_failure);
tree_[leads_to].AddMatches(tree_[follow_in_case_of_failure].matches());
}
}
}
-const uint32 SubstringSetMatcher::AhoCorasickNode::kNoSuchEdge = 0xFFFFFFFF;
+const uint32_t SubstringSetMatcher::AhoCorasickNode::kNoSuchEdge = 0xFFFFFFFF;
SubstringSetMatcher::AhoCorasickNode::AhoCorasickNode()
: failure_(kNoSuchEdge) {}
@@ -251,12 +252,12 @@ SubstringSetMatcher::AhoCorasickNode::operator=(
return *this;
}
-uint32 SubstringSetMatcher::AhoCorasickNode::GetEdge(char c) const {
+uint32_t SubstringSetMatcher::AhoCorasickNode::GetEdge(char c) const {
Edges::const_iterator i = edges_.find(c);
return i == edges_.end() ? kNoSuchEdge : i->second;
}
-void SubstringSetMatcher::AhoCorasickNode::SetEdge(char c, uint32 node) {
+void SubstringSetMatcher::AhoCorasickNode::SetEdge(char c, uint32_t node) {
edges_[c] = node;
}
« no previous file with comments | « components/url_matcher/substring_set_matcher.h ('k') | components/url_matcher/substring_set_matcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698