Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Unified Diff: src/objects.cc

Issue 769453002: add fast path for hashing small cons strings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 15fdce65d98a63d8a89c1edbc474e818ec634ee3..89451524076a19e5a7356515e00db8c9e2304bb7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -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()) {
« no previous file with comments | « no previous file | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698