Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index cb15a98b12cae59a0536892b14372ca4be284815..cf65b01cc5bceea73b1ab0c3245a9536e12685fa 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -10035,26 +10035,26 @@ bool String::Equals(const Instance& other) const { |
} |
-bool String::Equals(const char* utf8_array) const { |
- ASSERT(utf8_array != NULL); |
- intptr_t len = strlen(utf8_array); |
- for (intptr_t i = 0; i < this->Length(); ++i) { |
- if (*utf8_array == '\0') { |
+bool String::Equals(const char* str) const { |
siva
2012/11/20 19:47:32
yes cstr would be a better name.
Also please chang
cshapiro
2012/11/20 23:41:12
Done.
All of the C-strings in the dart VM are ass
|
+ ASSERT(str != NULL); |
+ CodePointIterator it(*this); |
+ intptr_t len = strlen(str); |
+ while (it.Next()) { |
+ if (*str == '\0') { |
// Lengths don't match. |
return false; |
} |
int32_t ch; |
- intptr_t consumed = Utf8::Decode( |
- reinterpret_cast<const uint8_t*>(utf8_array), |
- len, |
- &ch); |
- if (consumed == 0 || this->CharAt(i) != ch) { |
+ intptr_t consumed = Utf8::Decode(reinterpret_cast<const uint8_t*>(str), |
+ len, |
+ &ch); |
+ if (consumed == 0 || it.Current() != ch) { |
return false; |
} |
- utf8_array += consumed; |
+ str += consumed; |
len -= consumed; |
} |
- return *utf8_array == '\0'; |
+ return *str == '\0'; |
} |
siva
2012/11/20 19:47:32
We should add a test case for this in order to ens
cshapiro
2012/11/20 23:41:12
Done.
|