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

Unified Diff: frog/lib/corelib_impl.dart

Issue 8983019: Native implementation of List,setRange for frog. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 12 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 | tests/corelib/corelib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/lib/corelib_impl.dart
===================================================================
--- frog/lib/corelib_impl.dart (revision 2921)
+++ frog/lib/corelib_impl.dart (working copy)
@@ -72,7 +72,26 @@
List<E> getRange(int start, int length) native
"return this.slice(start, start + length);";
- void setRange(int start, int length, List<E> from, [int startFrom]) native;
+ void setRange(int start, int length, List<E> from, [int startFrom]) {
sra1 2012/01/05 18:38:44 Can you do [int startFrom = 0] ?
dominich 2012/01/05 18:53:21 Done.
+ // length of 0 prevails and should not throw exceptions.
+ if (length == 0) return;
+ if (length < 0) throw new IllegalArgumentException('length is negative');
+
+ if (start < 0) throw new IndexOutOfRangeException(start);
+
+ int end = start + length;
+ if (end > this.length) throw new IndexOutOfRangeException(end);
+
+ startFrom = (startFrom == null ? 0 : startFrom);
sra1 2012/01/05 18:38:44 This test would be unnecessary with the correct de
dominich 2012/01/05 18:53:21 Done.
+ if (startFrom < 0) throw new IndexOutOfRangeException(startFrom);
+
+ int endFrom = startFrom + length;
+ if (endFrom > from.length) throw new IndexOutOfRangeException(endFrom);
+
+ for (var i = 0; i < length; ++i)
+ this[start + i] = from[startFrom + i];
+ }
+
void removeRange(int start, int length) native "this.splice(start, length);";
void insertRange(int start, int length, [E initialValue]) native
« no previous file with comments | « no previous file | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698