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

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/js_array.dart

Issue 2927763004: Optimize runtime code on hot methods (Closed)
Patch Set: Created 3 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 | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/tool/input_sdk/private/js_string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/tool/input_sdk/private/js_array.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/js_array.dart b/pkg/dev_compiler/tool/input_sdk/private/js_array.dart
index dc9564eb0e507b5343d63b1585d9d1f4a308ea70..260f58d79819ec38525a6180cb72b3fb9d81586c 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/js_array.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/js_array.dart
@@ -558,15 +558,22 @@ class JSArray<E> implements List<E>, JSIndexable<E> {
}
E operator [](int index) {
- if (index is! int) throw diagnoseIndexError(this, index);
- if (index >= length || index < 0) throw diagnoseIndexError(this, index);
+ // Suppress redundant null checks via JS.
+ if (index == null ||
ochafik 2017/06/08 17:23:08 I wonder how hard it would be to implement naive f
+ JS('int', '#', index) >= JS('int', '#.length', this) ||
+ JS('int', '#', index) < 0) {
+ throw diagnoseIndexError(this, index);
+ }
return JS('var', '#[#]', this, index);
}
void operator []=(int index, E value) {
checkMutable('indexed set');
- if (index is! int) throw diagnoseIndexError(this, index);
- if (index >= length || index < 0) throw diagnoseIndexError(this, index);
+ if (index == null ||
+ JS('int', '#', index) >= JS('int', '#.length', this) ||
+ JS('int', '#', index) < 0) {
+ throw diagnoseIndexError(this, index);
+ }
JS('void', r'#[#] = #', this, index, value);
}
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/tool/input_sdk/private/js_string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698