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

Unified Diff: src/parser.cc

Issue 507051: Attempt to make \b\w+ faster. Slight performance increase on, e.g., string unpacking. (Closed)
Patch Set: Addressed review comments. Created 10 years, 11 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 | « src/jsregexp.cc ('k') | src/regexp-macro-assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 819b9b921c1abd05f7e306a4c600cbdb56ed5c47..e4d7392a528b6877f7711fc8fc3dc59a84946b12 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -371,7 +371,7 @@ class RegExpBuilder: public ZoneObject {
void AddAtom(RegExpTree* tree);
void AddAssertion(RegExpTree* tree);
void NewAlternative(); // '|'
- void AddQuantifierToAtom(int min, int max, bool is_greedy);
+ void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type);
RegExpTree* ToRegExp();
private:
void FlushCharacters();
@@ -503,7 +503,9 @@ RegExpTree* RegExpBuilder::ToRegExp() {
}
-void RegExpBuilder::AddQuantifierToAtom(int min, int max, bool is_greedy) {
+void RegExpBuilder::AddQuantifierToAtom(int min,
+ int max,
+ RegExpQuantifier::Type type) {
if (pending_empty_) {
pending_empty_ = false;
return;
@@ -543,7 +545,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min, int max, bool is_greedy) {
UNREACHABLE();
return;
}
- terms_.Add(new RegExpQuantifier(min, max, is_greedy, atom));
+ terms_.Add(new RegExpQuantifier(min, max, type, atom));
LAST(ADD_TERM);
}
@@ -4278,12 +4280,16 @@ RegExpTree* RegExpParser::ParseDisjunction() {
default:
continue;
}
- bool is_greedy = true;
+ RegExpQuantifier::Type type = RegExpQuantifier::GREEDY;
if (current() == '?') {
- is_greedy = false;
+ type = RegExpQuantifier::NON_GREEDY;
+ Advance();
+ } else if (FLAG_regexp_possessive_quantifier && current() == '+') {
+ // FLAG_regexp_possessive_quantifier is a debug-only flag.
+ type = RegExpQuantifier::POSSESSIVE;
Advance();
}
- builder->AddQuantifierToAtom(min, max, is_greedy);
+ builder->AddQuantifierToAtom(min, max, type);
}
}
« no previous file with comments | « src/jsregexp.cc ('k') | src/regexp-macro-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698