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

Unified Diff: compiler/lib/implementation/string.js

Issue 9192007: Simplify equality checks and get rid of unreachable code in number and bool. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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
Index: compiler/lib/implementation/string.js
diff --git a/compiler/lib/implementation/string.js b/compiler/lib/implementation/string.js
index 75e249236354d1e07b54a41c21cf5b04562825c0..5d643d54e10b2c1c6582bad5ee5d207dfd26f46f 100644
--- a/compiler/lib/implementation/string.js
+++ b/compiler/lib/implementation/string.js
@@ -18,8 +18,17 @@ function native_StringImplementation_get$length() {
}
function native_StringImplementation_EQ(other) {
- "use strict";
- return typeof other == 'string' && this == other;
+ // TODO(kasperl): We should really try to avoid having wrapped
+ // strings floating around. The usually stem from referencing [this]
mmendez 2012/01/19 17:09:47 Nit: the -> they.
+ // in Dart methods patched onto the String.prototype object.
+
+ // Because of the checks in EQ$operator, we know [this] is a string
+ // wrapper, but we have to make sure that [other] is either a
+ // wrapper or a proper string before we can use == to compare the
+ // contents.
+ return (typeof(other) == 'string' || other.constructor === String)
+ ? this == other
+ : false;
}
function native_StringImplementation__nativeIndexOf(other, startIndex) {

Powered by Google App Engine
This is Rietveld 408576698