Commit b76bf22c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Use CompareChars to compare Strings and Vector<Char>s

Change-Id: If5d5f45dbd7461db77d3da5ba050dbe67d87a442
Reviewed-on: https://chromium-review.googlesource.com/c/1342028
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57611}
parent f5b7d874
......@@ -12245,10 +12245,7 @@ bool String::IsOneByteEqualTo(Vector<const uint8_t> str) {
return CompareChars(content.ToOneByteVector().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;
return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0;
}
......@@ -12257,13 +12254,11 @@ bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
if (str.length() != slen) return false;
DisallowHeapAllocation no_gc;
FlatContent content = GetFlatContent();
if (content.IsTwoByte()) {
return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0;
}
for (int i = 0; i < slen; i++) {
if (Get(i) != str[i]) return false;
if (content.IsOneByte()) {
return CompareChars(content.ToOneByteVector().start(), str.start(), slen) ==
0;
}
return true;
return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0;
}
uint32_t String::ComputeAndSetHash(Isolate* isolate) {
......
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