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

Unified Diff: lib/compiler/implementation/lib/interceptors.dart

Issue 10553034: Stop mapping indexOf/lastIndexOf directly to the JavaScript native on indexable primitives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/interceptors.dart
diff --git a/lib/compiler/implementation/lib/interceptors.dart b/lib/compiler/implementation/lib/interceptors.dart
index 99e7fecdbf2a942ab3243b2f3ef1ae2fcc4d663e..e94d94c0561541e48c3118fb9b1fa18077684f09 100644
--- a/lib/compiler/implementation/lib/interceptors.dart
+++ b/lib/compiler/implementation/lib/interceptors.dart
@@ -187,8 +187,13 @@ getRange(receiver, start, length) {
}
indexOf$1(receiver, element) {
- if (isJsArray(receiver) || receiver is String) {
- return indexOf$2(receiver, element, 0);
+ if (isJsArray(receiver)) {
+ var length = JS('num', @'#.length', receiver);
+ return Arrays.indexOf(receiver, element, 0, length);
+ } else if (receiver is String) {
+ checkNull(element);
+ if (element is !String) throw new IllegalArgumentException(element);
+ return JS('int', @'#.indexOf(#)', receiver, element);
}
return UNINTERCEPTED(receiver.indexOf(element));
}
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698