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}
This commit is contained in:
parent
0de87ac84e
commit
660de644ae
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user