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

Unified Diff: trunk/src/extensions/common/matcher/substring_set_matcher.h

Issue 15045002: Revert 198803 "Speed improvements to SubstringSetMatcher" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | trunk/src/extensions/common/matcher/substring_set_matcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/extensions/common/matcher/substring_set_matcher.h
===================================================================
--- trunk/src/extensions/common/matcher/substring_set_matcher.h (revision 198804)
+++ trunk/src/extensions/common/matcher/substring_set_matcher.h (working copy)
@@ -5,7 +5,6 @@
#ifndef EXTENSIONS_COMMON_MATCHER_SUBSTRING_SET_MATCHER_H_
#define EXTENSIONS_COMMON_MATCHER_SUBSTRING_SET_MATCHER_H_
-#include <limits>
#include <map>
#include <set>
#include <string>
@@ -81,22 +80,21 @@
class AhoCorasickNode {
public:
// Key: label of the edge, value: node index in |tree_| of parent class.
- typedef std::map<char, uint32> Edges;
+ typedef std::map<char, int> Edges;
typedef std::set<StringPattern::ID> Matches;
- static const uint32 kNoSuchEdge = ~0;
-
AhoCorasickNode();
~AhoCorasickNode();
AhoCorasickNode(const AhoCorasickNode& other);
AhoCorasickNode& operator=(const AhoCorasickNode& other);
- uint32 GetEdge(char c) const;
- void SetEdge(char c, uint32 node);
+ bool HasEdge(char c) const;
+ int GetEdge(char c) const;
+ void SetEdge(char c, int node);
const Edges& edges() const { return edges_; }
- uint32 failure() const { return failure_; }
- void set_failure(uint32 failure) { failure_ = failure; }
+ int failure() const { return failure_; }
+ void set_failure(int failure) { failure_ = failure; }
void AddMatch(StringPattern::ID id);
void AddMatches(const Matches& matches);
@@ -107,18 +105,14 @@
Edges edges_;
// Node index that failure edge leads to.
- uint32 failure_;
+ int failure_;
// Identifiers of matches.
Matches matches_;
};
- typedef std::map<StringPattern::ID, const StringPattern*> SubstringPatternMap;
- typedef std::vector<const StringPattern*> SubstringPatternVector;
+ void RebuildAhoCorasickTree();
- // |sorted_patterns| is a copy of |patterns_| sorted by the pattern string.
- void RebuildAhoCorasickTree(const SubstringPatternVector& sorted_patterns);
-
// Inserts a path for |pattern->pattern()| into the tree and adds
// |pattern->id()| to the set of matches. Ownership of |pattern| remains with
// the caller.
@@ -127,7 +121,9 @@
// Set of all registered StringPatterns. Used to regenerate the
// Aho-Corasick tree in case patterns are registered or unregistered.
- SubstringPatternMap patterns_;
+ typedef std::map<StringPattern::ID, const StringPattern*>
+ SubstringPatternSet;
+ SubstringPatternSet patterns_;
// The nodes of a Aho-Corasick tree.
std::vector<AhoCorasickNode> tree_;
« no previous file with comments | « no previous file | trunk/src/extensions/common/matcher/substring_set_matcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698