Chromium Code Reviews| Index: runtime/vm/object.h |
| diff --git a/runtime/vm/object.h b/runtime/vm/object.h |
| index 1715a13a293a8ae1b354697908eb522cd39752a3..308a02c7defd77a114aa2a4a84feafbcf3e16303 100644 |
| --- a/runtime/vm/object.h |
| +++ b/runtime/vm/object.h |
| @@ -6288,6 +6288,7 @@ class String : public Instance { |
| this->SetHash(result); |
| return result; |
| } |
| + |
| bool HasHash() const { |
| ASSERT(Smi::New(0) == NULL); |
| return (raw_ptr()->hash_ != NULL); |
| @@ -6317,9 +6318,10 @@ class String : public Instance { |
| intptr_t CharSize() const; |
| inline bool Equals(const String& str) const; |
| - inline bool Equals(const String& str, |
| - intptr_t begin_index, // begin index on 'str'. |
| - intptr_t len) const; // len on 'str'. |
| + |
| + bool Equals(const String& str, |
| + intptr_t begin_index, // begin index on 'str'. |
| + intptr_t len) const; // len on 'str'. |
| // Compares to a '\0' terminated array of UTF-8 encoded characters. |
| bool Equals(const char* cstr) const; |
| @@ -8354,26 +8356,13 @@ bool String::Equals(const String& str) const { |
| if (str.IsNull()) { |
|
kasperl
2016/02/05 05:09:26
This takes care of the null check I removed from S
Ivan Posva
2016/02/05 05:57:42
Acknowledged.
|
| return false; |
| } |
| - return Equals(str, 0, str.Length()); |
| -} |
| - |
| - |
| -bool String::Equals(const String& str, |
| - intptr_t begin_index, |
| - intptr_t len) const { |
| - ASSERT(begin_index >= 0); |
| - ASSERT((begin_index == 0) || (begin_index < str.Length())); |
| - ASSERT(len >= 0); |
| - ASSERT(len <= str.Length()); |
| - if (len != this->Length()) { |
| - return false; // Lengths don't match. |
| + if (IsCanonical() && str.IsCanonical()) { |
| + return false; // Two symbols that aren't identical aren't equal. |
| } |
| - for (intptr_t i = 0; i < len; i++) { |
| - if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| - return false; |
| - } |
| + if (HasHash() && str.HasHash() && (Hash() != str.Hash())) { |
| + return false; // Both sides have hash codes and they do not match. |
| } |
| - return true; |
| + return Equals(str, 0, str.Length()); |
| } |