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

Unified Diff: test/cctest/test-regexp.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/x64/regexp-macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-regexp.cc
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 6aa0730c0d776f9321f58cfd2692bd8d3feeadc8..4e49839689ed4571e71f69ca6529f11e26077275 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -1550,7 +1550,68 @@ TEST(CharClassDifference) {
}
+TEST(CanonicalizeCharacterSets) {
+ ZoneScope scope(DELETE_ON_EXIT);
+ ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4);
+ CharacterSet set(list);
+
+ list->Add(CharacterRange(10, 20));
+ list->Add(CharacterRange(30, 40));
+ list->Add(CharacterRange(50, 60));
+ set.Canonicalize();
+ ASSERT_EQ(3, list->length());
+ ASSERT_EQ(10, list->at(0).from());
+ ASSERT_EQ(20, list->at(0).to());
+ ASSERT_EQ(30, list->at(1).from());
+ ASSERT_EQ(40, list->at(1).to());
+ ASSERT_EQ(50, list->at(2).from());
+ ASSERT_EQ(60, list->at(2).to());
+
+ list->Rewind(0);
+ list->Add(CharacterRange(10, 20));
+ list->Add(CharacterRange(50, 60));
+ list->Add(CharacterRange(30, 40));
+ set.Canonicalize();
+ ASSERT_EQ(3, list->length());
+ ASSERT_EQ(10, list->at(0).from());
+ ASSERT_EQ(20, list->at(0).to());
+ ASSERT_EQ(30, list->at(1).from());
+ ASSERT_EQ(40, list->at(1).to());
+ ASSERT_EQ(50, list->at(2).from());
+ ASSERT_EQ(60, list->at(2).to());
+
+ list->Rewind(0);
+ list->Add(CharacterRange(30, 40));
+ list->Add(CharacterRange(10, 20));
+ list->Add(CharacterRange(25, 25));
+ list->Add(CharacterRange(100, 100));
+ list->Add(CharacterRange(1, 1));
+ set.Canonicalize();
+ ASSERT_EQ(5, list->length());
+ ASSERT_EQ(1, list->at(0).from());
+ ASSERT_EQ(1, list->at(0).to());
+ ASSERT_EQ(10, list->at(1).from());
+ ASSERT_EQ(20, list->at(1).to());
+ ASSERT_EQ(25, list->at(2).from());
+ ASSERT_EQ(25, list->at(2).to());
+ ASSERT_EQ(30, list->at(3).from());
+ ASSERT_EQ(40, list->at(3).to());
+ ASSERT_EQ(100, list->at(4).from());
+ ASSERT_EQ(100, list->at(4).to());
+
+ list->Rewind(0);
+ list->Add(CharacterRange(10, 19));
+ list->Add(CharacterRange(21, 30));
+ list->Add(CharacterRange(20, 20));
+ set.Canonicalize();
+ ASSERT_EQ(1, list->length());
+ ASSERT_EQ(10, list->at(0).from());
+ ASSERT_EQ(30, list->at(0).to());
+}
+
+
+
TEST(Graph) {
V8::Initialize(NULL);
- Execute("(?:(?:x(.))?\1)+$", false, true, true);
+ Execute("\\b\\w+\\b", false, true, true);
}
« no previous file with comments | « src/x64/regexp-macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698