Commit 660de644 authored by dcarney's avatar dcarney Committed by Commit bot

add fast path for hashing small cons strings

R=yangguo@chromium.org
LOG=N

BUG=437280

Review URL: https://codereview.chromium.org/769453002

Cr-Commit-Position: refs/heads/master@{#25562}
parent 0de87ac8
......@@ -6828,9 +6828,8 @@ uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) {
// Nothing to do.
if (hasher.has_trivial_hash()) return hasher.GetHashField();
ConsString* cons_string = String::VisitFlat(&hasher, string);
if (cons_string != nullptr) {
hasher.VisitConsString(cons_string);
}
if (cons_string == nullptr) return hasher.GetHashField();
hasher.VisitConsString(cons_string);
return hasher.GetHashField();
}
......
......@@ -9298,6 +9298,18 @@ uint32_t StringHasher::ComputeUtf8Hash(Vector<const char> chars,
void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
// Run small ConsStrings through ConsStringIterator.
if (cons_string->length() < 64) {
ConsStringIterator iter(cons_string);
int offset;
String* string;
while (nullptr != (string = iter.Next(&offset))) {
DCHECK_EQ(0, offset);
String::VisitFlat(this, string, 0);
}
return;
}
// Slow case.
const int max_length = String::kMaxHashCalcLength;
int length = std::min(cons_string->length(), max_length);
if (cons_string->HasOnlyOneByteChars()) {
......
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