Commit 6a1b70cc authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Regexp: Unify the lookahead code for the BoyerMoore-like skipping

and the lookahead code for simplifying \b.  Also cache lookahead
results on the nodes, fix a memory leak and remove some character
class code we are no longer using.
Review URL: https://chromiumcodereview.appspot.com/9961009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11345 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2d757afa
This diff is collapsed.
This diff is collapsed.
......@@ -1590,7 +1590,7 @@ TEST(CharClassDifference) {
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
ZoneList<CharacterRange>* base = new ZoneList<CharacterRange>(1);
base->Add(CharacterRange::Everything());
Vector<const uc16> overlay = CharacterRange::GetWordBounds();
Vector<const int> overlay = CharacterRange::GetWordBounds();
ZoneList<CharacterRange>* included = NULL;
ZoneList<CharacterRange>* excluded = NULL;
CharacterRange::Split(base, overlay, &included, &excluded);
......@@ -1599,7 +1599,7 @@ TEST(CharClassDifference) {
if (in_base) {
bool in_overlay = false;
for (int j = 0; !in_overlay && j < overlay.length(); j += 2) {
if (overlay[j] <= i && i <= overlay[j+1])
if (overlay[j] <= i && i < overlay[j+1])
in_overlay = true;
}
CHECK_EQ(in_overlay, InClass(i, included));
......@@ -1672,16 +1672,6 @@ TEST(CanonicalizeCharacterSets) {
ASSERT_EQ(30, list->at(0).to());
}
// Checks whether a character is in the set represented by a list of ranges.
static bool CharacterInSet(ZoneList<CharacterRange>* set, uc16 value) {
for (int i = 0; i < set->length(); i++) {
CharacterRange range = set->at(i);
if (range.from() <= value && value <= range.to()) {
return true;
}
}
return false;
}
TEST(CharacterRangeMerge) {
v8::internal::V8::Initialize(NULL);
......@@ -1768,67 +1758,6 @@ TEST(CharacterRangeMerge) {
ZoneList<CharacterRange> first_only(4);
ZoneList<CharacterRange> second_only(4);
ZoneList<CharacterRange> both(4);
// Merge one direction.
CharacterRange::Merge(&l1, &l2, &first_only, &second_only, &both);
CHECK(CharacterRange::IsCanonical(&first_only));
CHECK(CharacterRange::IsCanonical(&second_only));
CHECK(CharacterRange::IsCanonical(&both));
for (uc16 i = 0; i < offset; i++) {
bool in_first = CharacterInSet(&l1, i);
bool in_second = CharacterInSet(&l2, i);
CHECK((in_first && !in_second) == CharacterInSet(&first_only, i));
CHECK((!in_first && in_second) == CharacterInSet(&second_only, i));
CHECK((in_first && in_second) == CharacterInSet(&both, i));
}
first_only.Clear();
second_only.Clear();
both.Clear();
// Merge other direction.
CharacterRange::Merge(&l2, &l1, &second_only, &first_only, &both);
CHECK(CharacterRange::IsCanonical(&first_only));
CHECK(CharacterRange::IsCanonical(&second_only));
CHECK(CharacterRange::IsCanonical(&both));
for (uc16 i = 0; i < offset; i++) {
bool in_first = CharacterInSet(&l1, i);
bool in_second = CharacterInSet(&l2, i);
CHECK((in_first && !in_second) == CharacterInSet(&first_only, i));
CHECK((!in_first && in_second) == CharacterInSet(&second_only, i));
CHECK((in_first && in_second) == CharacterInSet(&both, i));
}
first_only.Clear();
second_only.Clear();
both.Clear();
// Merge but don't record all combinations.
CharacterRange::Merge(&l1, &l2, NULL, NULL, &both);
CHECK(CharacterRange::IsCanonical(&both));
for (uc16 i = 0; i < offset; i++) {
bool in_first = CharacterInSet(&l1, i);
bool in_second = CharacterInSet(&l2, i);
CHECK((in_first && in_second) == CharacterInSet(&both, i));
}
// Merge into same set.
ZoneList<CharacterRange> all(4);
CharacterRange::Merge(&l1, &l2, &all, &all, &all);
CHECK(CharacterRange::IsCanonical(&all));
for (uc16 i = 0; i < offset; i++) {
bool in_first = CharacterInSet(&l1, i);
bool in_second = CharacterInSet(&l2, i);
CHECK((in_first || in_second) == CharacterInSet(&all, i));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment