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

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
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..e01bb146ee8cec301f52e4be0070042a9aee99de 100644
--- a/sdk/lib/web_sql/dartium/web_sql_dartium.dart
+++ b/sdk/lib/web_sql/dartium/web_sql_dartium.dart
@@ -217,7 +217,11 @@ 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 +234,34 @@ 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) {
+ return this[index];
+ }
+
// -- end List<Map> mixins.
@DomName('SQLResultSetRowList.item')

Powered by Google App Engine
This is Rietveld 408576698