Chromium Code Reviews| Index: vm/object.h |
| =================================================================== |
| --- vm/object.h (revision 9647) |
| +++ vm/object.h (working copy) |
| @@ -3188,16 +3188,10 @@ |
| virtual intptr_t CharSize() const; |
| - bool Equals(const String& str) const { |
| - if (raw() == str.raw()) { |
| - return true; // Both handles point to the same raw instance. |
| - } |
| - if (str.IsNull()) { |
| - return false; |
| - } |
| - return Equals(str, 0, str.Length()); |
| - } |
| - bool Equals(const String& str, intptr_t begin_index, intptr_t len) const; |
| + inline bool Equals(const String& str) const; |
| + inline bool Equals(const String& str, |
| + intptr_t begin_index, |
| + intptr_t len) const; |
| bool Equals(const char* str) const; |
| bool Equals(const uint8_t* characters, intptr_t len) const; |
| bool Equals(const uint16_t* characters, intptr_t len) const; |
| @@ -5138,6 +5132,36 @@ |
| return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| } |
| + |
| +bool String::Equals(const String& str) const { |
| + if (raw() == str.raw()) { |
| + return true; // Both handles point to the same raw instance. |
| + } |
| + if (str.IsNull()) { |
| + 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); |
|
srdjan
2012/07/13 23:22:23
Compare raws as well.
siva
2012/07/16 18:29:23
I don't think we can do a raw comparision and retu
|
| + ASSERT(begin_index == 0 || begin_index < str.Length()); |
|
srdjan
2012/07/13 23:22:23
Add parenthesis
siva
2012/07/16 18:29:23
Done.
|
| + ASSERT(len >= 0); |
| + ASSERT(len <= str.Length()); |
| + if (len != this->Length()) { |
| + return false; // Lengths don't match. |
| + } |
| + for (intptr_t i = 0; i < len; i++) { |
| + if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| + return false; |
| + } |
| + } |
| + return true; |
| +} |
| + |
| } // namespace dart |
| #endif // VM_OBJECT_H_ |