| Index: src/objects-inl.h
|
| diff --git a/src/objects-inl.h b/src/objects-inl.h
|
| index fb996a219e28df171504916345c496394ab4c3c1..961041c05dd22d13be79a10564fd8f17bae0005f 100644
|
| --- a/src/objects-inl.h
|
| +++ b/src/objects-inl.h
|
| @@ -499,17 +499,21 @@ class OneByteStringKey : public SequentialStringKey<uint8_t> {
|
| };
|
|
|
|
|
| -class SubStringOneByteStringKey : public HashTableKey {
|
| +template<class Char>
|
| +class SubStringKey : public HashTableKey {
|
| public:
|
| - explicit SubStringOneByteStringKey(Handle<SeqOneByteString> string,
|
| - int from,
|
| - int length)
|
| - : string_(string), from_(from), length_(length) { }
|
| + SubStringKey(Handle<String> string, int from, int length)
|
| + : string_(string), from_(from), length_(length) {
|
| + if (string_->IsSlicedString()) {
|
| + string_ = Handle<String>(Unslice(*string_, &from_));
|
| + }
|
| + ASSERT(string_->IsSeqString() || string->IsExternalString());
|
| + }
|
|
|
| virtual uint32_t Hash() {
|
| ASSERT(length_ >= 0);
|
| ASSERT(from_ + length_ <= string_->length());
|
| - uint8_t* chars = string_->GetChars() + from_;
|
| + const Char* chars = GetChars() + from_;
|
| hash_field_ = StringHasher::HashSequentialString(
|
| chars, length_, string_->GetHeap()->HashSeed());
|
| uint32_t result = hash_field_ >> String::kHashShift;
|
| @@ -517,20 +521,25 @@ class SubStringOneByteStringKey : public HashTableKey {
|
| return result;
|
| }
|
|
|
| -
|
| virtual uint32_t HashForObject(Object* other) {
|
| return String::cast(other)->Hash();
|
| }
|
|
|
| - virtual bool IsMatch(Object* string) {
|
| - Vector<const uint8_t> chars(string_->GetChars() + from_, length_);
|
| - return String::cast(string)->IsOneByteEqualTo(chars);
|
| - }
|
| -
|
| + virtual bool IsMatch(Object* string);
|
| virtual MaybeObject* AsObject(Heap* heap);
|
|
|
| private:
|
| - Handle<SeqOneByteString> string_;
|
| + const Char* GetChars();
|
| + String* Unslice(String* string, int* offset) {
|
| + while (string->IsSlicedString()) {
|
| + SlicedString* sliced = SlicedString::cast(string);
|
| + *offset += sliced->offset();
|
| + string = sliced->parent();
|
| + }
|
| + return string;
|
| + }
|
| +
|
| + Handle<String> string_;
|
| int from_;
|
| int length_;
|
| uint32_t hash_field_;
|
|
|