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

Unified Diff: sdk/lib/web_sql/dartium/web_sql_dartium.dart

Issue 14619013: Explicitly implementing some DOM iterable APIs for performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tests/html/node_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/web_sql/dartium/web_sql_dartium.dart
diff --git a/sdk/lib/web_sql/dartium/web_sql_dartium.dart b/sdk/lib/web_sql/dartium/web_sql_dartium.dart
index c7c3bc00c1e0ac7e17f1021006f16bf77bfb7e4e..c72e56f75320c34aa74e54c8ca68ec6d6b8df581 100644
--- a/sdk/lib/web_sql/dartium/web_sql_dartium.dart
+++ b/sdk/lib/web_sql/dartium/web_sql_dartium.dart
@@ -217,7 +217,12 @@ class SqlResultSetRowList extends NativeFieldWrapperClass1 with ListMixin<Map>,
@DocsEditable
int get length native "SQLResultSetRowList_length_Getter";
- Map operator[](int index) native "SQLResultSetRowList_item_Callback";
+ Map operator[](int index) {
+ if (index < 0 || index >= length)
+ throw new RangeError.range(index, 0, length);
+ return _nativeIndexedGetter(index);
+ }
+ Map _nativeIndexedGetter(int index) native "SQLResultSetRowList_item_Callback";
void operator[]=(int index, Map value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
@@ -230,6 +235,31 @@ class SqlResultSetRowList extends NativeFieldWrapperClass1 with ListMixin<Map>,
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Map get first {
+ if (this.length > 0) {
+ return this[0];
+ }
+ throw new StateError("No elements");
+ }
+
+ Map get last {
+ int len = this.length;
+ if (len > 0) {
+ return this[len - 1];
+ }
+ throw new StateError("No elements");
+ }
+
+ Map get single {
+ int len = this.length;
+ if (len == 1) {
+ return this[0];
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Map elementAt(int index) => this[index];
// -- end List<Map> mixins.
@DomName('SQLResultSetRowList.item')
« no previous file with comments | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tests/html/node_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698