Remove unique static RegExpEmpty instance.
R=marja@chromium.org BUG=chromium:430652 LOG=N Review URL: https://codereview.chromium.org/716113002 Cr-Commit-Position: refs/heads/master@{#25284} git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25284 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
434f2ebb5b
commit
089ed6e09f
@ -3117,10 +3117,6 @@ class RegExpEmpty FINAL : public RegExpTree {
|
|||||||
virtual bool IsEmpty() OVERRIDE;
|
virtual bool IsEmpty() OVERRIDE;
|
||||||
virtual int min_match() OVERRIDE { return 0; }
|
virtual int min_match() OVERRIDE { return 0; }
|
||||||
virtual int max_match() OVERRIDE { return 0; }
|
virtual int max_match() OVERRIDE { return 0; }
|
||||||
static RegExpEmpty* GetInstance() {
|
|
||||||
static RegExpEmpty* instance = ::new RegExpEmpty();
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void RegExpBuilder::FlushTerms() {
|
|||||||
int num_terms = terms_.length();
|
int num_terms = terms_.length();
|
||||||
RegExpTree* alternative;
|
RegExpTree* alternative;
|
||||||
if (num_terms == 0) {
|
if (num_terms == 0) {
|
||||||
alternative = RegExpEmpty::GetInstance();
|
alternative = new (zone()) RegExpEmpty();
|
||||||
} else if (num_terms == 1) {
|
} else if (num_terms == 1) {
|
||||||
alternative = terms_.last();
|
alternative = terms_.last();
|
||||||
} else {
|
} else {
|
||||||
@ -126,12 +126,8 @@ void RegExpBuilder::FlushTerms() {
|
|||||||
RegExpTree* RegExpBuilder::ToRegExp() {
|
RegExpTree* RegExpBuilder::ToRegExp() {
|
||||||
FlushTerms();
|
FlushTerms();
|
||||||
int num_alternatives = alternatives_.length();
|
int num_alternatives = alternatives_.length();
|
||||||
if (num_alternatives == 0) {
|
if (num_alternatives == 0) return new (zone()) RegExpEmpty();
|
||||||
return RegExpEmpty::GetInstance();
|
if (num_alternatives == 1) return alternatives_.last();
|
||||||
}
|
|
||||||
if (num_alternatives == 1) {
|
|
||||||
return alternatives_.last();
|
|
||||||
}
|
|
||||||
return new(zone()) RegExpDisjunction(alternatives_.GetList(zone()));
|
return new(zone()) RegExpDisjunction(alternatives_.GetList(zone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user