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; |
|
srdjan
2012/07/16 20:42:07
Add comment: begin_index of 'str' or 'this'?
siva
2012/07/17 19:15:21
Done.
|
| 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; |
| @@ -3340,6 +3334,8 @@ |
| RawOneByteString* EscapeDoubleQuotes() const; |
| + bool EqualsIgnoringPrivate(const OneByteString& str) const; |
|
srdjan
2012/07/16 20:42:07
I think it would be clearer to name it EqualsIgnor
siva
2012/07/17 19:15:21
Done.
|
| + |
| static intptr_t data_offset() { return OFFSET_OF(RawOneByteString, data_); } |
| static intptr_t InstanceSize() { |
| @@ -3353,6 +3349,12 @@ |
| static RawOneByteString* New(intptr_t len, |
| Heap::Space space); |
| + static RawOneByteString* New(const char* c_string, |
| + Heap::Space space = Heap::kNew) { |
| + return New(reinterpret_cast<const uint8_t*>(c_string), |
| + strlen(c_string), |
| + space); |
| + } |
| static RawOneByteString* New(const uint8_t* characters, |
| intptr_t len, |
| Heap::Space space); |
| @@ -5138,6 +5140,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); |
| + 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. |
| + } |
| + 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_ |