// Nothing to do.
if (hasher.has_trivial_hash()) return hasher.GetHashField();
ConsString* cons_string = String::VisitFlat(&hasher, string);
- // The string was flat.
- if (cons_string == NULL) return hasher.GetHashField();
- // This is a ConsString, iterate across it.
- ConsStringIterator iter(cons_string);
- int offset;
- while (NULL != (string = iter.Next(&offset))) {
- String::VisitFlat(&hasher, string, offset);
+ if (cons_string != nullptr) {
+ hasher.VisitConsString(cons_string);
}
return hasher.GetHashField();
}
}
+void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
+ const int max_length = String::kMaxHashCalcLength;
+ int length = std::min(cons_string->length(), max_length);
+ if (cons_string->HasOnlyOneByteChars()) {
+ uint8_t* buffer = new uint8_t[length];
+ String::WriteToFlat(cons_string, buffer, 0, length);
+ AddCharacters(buffer, length);
+ delete[] buffer;
+ } else {
+ uint16_t* buffer = new uint16_t[length];
+ String::WriteToFlat(cons_string, buffer, 0, length);
+ AddCharacters(buffer, length);
+ delete[] buffer;
+ }
+}
+
+
void String::PrintOn(FILE* file) {
int length = this->length();
for (int i = 0; i < length; i++) {
class AllocationSite;
class AllocationSiteCreationContext;
class AllocationSiteUsageContext;
+class ConsString;
class DictionaryElementsAccessor;
class ElementsAccessor;
class FixedArrayBase;
private:
inline IteratingStringHasher(int len, uint32_t seed)
: StringHasher(len, seed) {}
+ void VisitConsString(ConsString* cons_string);
DISALLOW_COPY_AND_ASSIGN(IteratingStringHasher);
};