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

Unified Diff: vm/object.cc

Issue 10785007: Minor changes based on the profile while running dart2js compile all. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months 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
« vm/object.h ('K') | « vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/object.cc
===================================================================
--- vm/object.cc (revision 9647)
+++ vm/object.cc (working copy)
@@ -1929,8 +1929,8 @@
}
-// Check to see if mangled_name is equal to bare_name once the private
-// key separator is stripped from mangled_name.
+// Check to see if 'lookup_name' matches 'name' as is or
+// once the private key separator is stripped from name.
//
// Things are made more complicated by the fact that constructors are
// added *after* the private suffix, so "foo@123.named" should match
@@ -1940,40 +1940,44 @@
//
// _ReceivePortImpl@6be832b._internal@6be832b
//
-bool EqualsIgnoringPrivate(const String& mangled_name,
- const String& bare_name) {
- intptr_t mangled_len = mangled_name.Length();
- intptr_t bare_len = bare_name.Length();
- if (mangled_len < bare_len) {
- // No way they can match.
- return false;
+bool EqualsIgnoringPrivate(const String& name, const String& lookup_name) {
srdjan 2012/07/13 23:22:23 Compare raws.
siva 2012/07/16 18:29:23 Done.
+ intptr_t name_len = name.Length();
+ intptr_t lookup_name_len = lookup_name.Length();
+ if (name_len == lookup_name_len) {
+ for (intptr_t i = 0; i < name_len; i++) {
+ if (name.CharAt(i) != lookup_name.CharAt(i)) {
+ return false;
+ }
+ }
+ return true;
}
+ if (name_len < lookup_name_len) {
+ return false; // No way they can match.
+ }
+ intptr_t name_pos = 0;
+ intptr_t lookup_name_pos = 0;
+ while (name_pos < name_len) {
+ int32_t name_char = name.CharAt(name_pos);
+ name_pos++;
- intptr_t mangled_pos = 0;
- intptr_t bare_pos = 0;
- while (mangled_pos < mangled_len) {
- int32_t mangled_char = mangled_name.CharAt(mangled_pos);
- mangled_pos++;
-
- if (mangled_char == Scanner::kPrivateKeySeparator) {
+ if (name_char == Scanner::kPrivateKeySeparator) {
// Consume a private key separator.
- while (mangled_pos < mangled_len &&
- mangled_name.CharAt(mangled_pos) != '.') {
- mangled_pos++;
+ while (name_pos < name_len && name.CharAt(name_pos) != '.') {
+ name_pos++;
}
-
// Resume matching characters.
continue;
}
- if (bare_pos == bare_len || mangled_char != bare_name.CharAt(bare_pos)) {
+ if (lookup_name_pos == lookup_name_len ||
+ name_char != lookup_name.CharAt(lookup_name_pos)) {
return false;
}
- bare_pos++;
+ lookup_name_pos++;
}
- // The strings match if we have reached the end of both strings.
- return (mangled_pos == mangled_len &&
- bare_pos == bare_len);
+ // We have reached the end of mangled_name string.
+ ASSERT(name_pos == name_len);
+ return (lookup_name_pos == lookup_name_len);
}
@@ -1986,8 +1990,7 @@
for (intptr_t i = 0; i < len; i++) {
function ^= funcs.At(i);
function_name ^= function.name();
- if (function_name.Equals(name) ||
- EqualsIgnoringPrivate(function_name, name)) {
+ if (EqualsIgnoringPrivate(function_name, name)) {
return function.raw();
}
}
@@ -2089,7 +2092,7 @@
for (intptr_t i = 0; i < len; i++) {
field ^= flds.At(i);
field_name ^= field.name();
- if (field_name.Equals(name) || EqualsIgnoringPrivate(field_name, name)) {
+ if (EqualsIgnoringPrivate(field_name, name)) {
return field.raw();
}
}
@@ -8303,46 +8306,12 @@
const String& other_string = String::Cast(other);
if (this->HasHash() && other_string.HasHash() &&
(this->Hash() != other_string.Hash())) {
- // Both sides have a hash code and it does not match.
- return false;
+ return false; // Both sides have a hash code and it does not match.
}
-
- intptr_t len = this->Length();
- if (len != other_string.Length()) {
- // Lengths don't match.
- return false;
- }
-
- for (intptr_t i = 0; i < len; i++) {
- if (this->CharAt(i) != other_string.CharAt(i)) {
- return false;
- }
- }
- return true;
+ return Equals(other_string, 0, other_string.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()) {
- // Lengths don't match.
- return false;
- }
-
- for (intptr_t i = 0; i < len; i++) {
- if (this->CharAt(i) != str.CharAt(begin_index + i)) {
- return false;
- }
- }
- return true;
-}
-
-
bool String::Equals(const char* str) const {
for (intptr_t i = 0; i < this->Length(); ++i) {
if (*str == '\0') {
« vm/object.h ('K') | « vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698