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

Unified Diff: src/runtime.cc

Issue 6525: Calculate string hash during flattening. (Closed)
Patch Set: Created 12 years, 2 months 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
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index be1dbcddd3b64f06e22019a770e5073e32697b70..1b9233f0910a4f151d48ef65b102b2da48dc2b36 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -2380,21 +2380,24 @@ static Object* Runtime_StringBuilderConcat(Arguments args) {
if (object->IsFailure()) return object;
String* answer = String::cast(object);
+ StringHasher hasher(length);
for (int i = 0; i < array_length; i++) {
Object* element = fixed_array->get(i);
if (element->IsSmi()) {
int len = Smi::cast(element)->value();
int pos = len >> 11;
len &= 0x7ff;
- String::Flatten(special, answer, pos, pos + len, position);
+ String::Flatten(special, answer, pos, pos + len, position, &hasher);
position += len;
} else {
String* string = String::cast(element);
int element_length = string->length();
- String::Flatten(string, answer, 0, element_length, position);
+ String::Flatten(string, answer, 0, element_length, position, &hasher);
position += element_length;
}
}
+ if (hasher.is_valid())
+ answer->set_length_field(hasher.GetHashField());
return answer;
}
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698