Commit b230249a authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Add fast cases for flat comparison to String::Is{Ascii,TwoByte}EqualTo.

R=ager@chromium.org

Review URL: http://codereview.chromium.org/7064017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8065 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3766a315
......@@ -5534,16 +5534,11 @@ bool String::IsEqualTo(Vector<const char> str) {
bool String::IsAsciiEqualTo(Vector<const char> str) {
int slen = length();
if (str.length() != slen) return false;
if (this->IsSeqAsciiString()) {
SeqAsciiString* seq = SeqAsciiString::cast(this);
char* ch = seq->GetChars();
for (int i = 0; i < slen; i++, ch++) {
if (*ch != str[i]) return false;
}
} else {
for (int i = 0; i < slen; i++) {
if (Get(i) != static_cast<uint16_t>(str[i])) return false;
}
if (IsFlat() && IsAsciiRepresentation()) {
return CompareChars(ToAsciiVector().start(), str.start(), slen) == 0;
}
for (int i = 0; i < slen; i++) {
if (Get(i) != static_cast<uint16_t>(str[i])) return false;
}
return true;
}
......@@ -5552,6 +5547,9 @@ bool String::IsAsciiEqualTo(Vector<const char> str) {
bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
int slen = length();
if (str.length() != slen) return false;
if (IsFlat() && IsTwoByteRepresentation()) {
return CompareChars(ToUC16Vector().start(), str.start(), slen) == 0;
}
for (int i = 0; i < slen; i++) {
if (Get(i) != str[i]) return false;
}
......
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