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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 function native_StringImplementation__indexOperator(index) { 5 function native_StringImplementation__indexOperator(index) {
6 "use strict"; 6 "use strict";
7 return this[index]; 7 return this[index];
8 } 8 }
9 9
10 function native_StringImplementation__charCodeAt(index) { 10 function native_StringImplementation__charCodeAt(index) {
11 "use strict"; 11 "use strict";
12 return this.charCodeAt(index); 12 return this.charCodeAt(index);
13 } 13 }
14 14
15 function native_StringImplementation_get$length() { 15 function native_StringImplementation_get$length() {
16 "use strict"; 16 "use strict";
17 return this.length; 17 return this.length;
18 } 18 }
19 19
20 function native_StringImplementation_EQ(other) { 20 function native_StringImplementation_EQ(other) {
21 "use strict"; 21 // TODO(kasperl): We should really try to avoid having wrapped
22 return typeof other == 'string' && this == other; 22 // strings floating around. The usually stem from referencing [this]
mmendez 2012/01/19 17:09:47 Nit: the -> they.
23 // in Dart methods patched onto the String.prototype object.
24
25 // Because of the checks in EQ$operator, we know [this] is a string
26 // wrapper, but we have to make sure that [other] is either a
27 // wrapper or a proper string before we can use == to compare the
28 // contents.
29 return (typeof(other) == 'string' || other.constructor === String)
30 ? this == other
31 : false;
23 } 32 }
24 33
25 function native_StringImplementation__nativeIndexOf(other, startIndex) { 34 function native_StringImplementation__nativeIndexOf(other, startIndex) {
26 "use strict"; 35 "use strict";
27 return this.indexOf(other, startIndex); 36 return this.indexOf(other, startIndex);
28 } 37 }
29 38
30 function native_StringImplementation__nativeLastIndexOf(other, fromIndex) { 39 function native_StringImplementation__nativeLastIndexOf(other, fromIndex) {
31 "use strict"; 40 "use strict";
32 if (other == "") { 41 if (other == "") {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 144 }
136 array = tmp; 145 array = tmp;
137 } 146 }
138 return String.fromCharCode.apply(this, array); 147 return String.fromCharCode.apply(this, array);
139 } 148 }
140 149
141 // Deprecated old name of new String.fromValues(..). 150 // Deprecated old name of new String.fromValues(..).
142 function native_StringBase_createFromCharCodes(array) { 151 function native_StringBase_createFromCharCodes(array) {
143 return native_StringImplementation__newFromValues(array); 152 return native_StringImplementation__newFromValues(array);
144 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698