Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: runtime/vm/object.cc

Issue 11418095: Use the code point iterator in equality comparisons to C strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index cb15a98b12cae59a0536892b14372ca4be284815..09e077659a603d17fec18ce1a5ce607dab103125 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* cstr) const {
+ ASSERT(cstr != NULL);
+ CodePointIterator it(*this);
+ intptr_t len = strlen(cstr);
+ while (it.Next()) {
+ if (*cstr == '\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*>(cstr),
+ len,
+ &ch);
+ if (consumed == 0 || it.Current() != ch) {
return false;
}
- utf8_array += consumed;
+ cstr += consumed;
len -= consumed;
}
- return *utf8_array == '\0';
+ return *cstr == '\0';
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698