Chromium Code Reviews| Index: frog/lib/corelib_impl.dart |
| diff --git a/frog/lib/corelib_impl.dart b/frog/lib/corelib_impl.dart |
| index 4cee364e97e1f427dd7e6b8a0eae949f8011d04a..9a25e1a1162b13824e8b3c98bffcbf51070d4528 100644 |
| --- a/frog/lib/corelib_impl.dart |
| +++ b/frog/lib/corelib_impl.dart |
| @@ -68,8 +68,17 @@ class ListFactory<E> implements List<E> native "Array" { |
| "return this.slice(start, start + length);"; |
| void setRange(int start, int length, List<E> from, [int startFrom]) native; |
| - void removeRange(int start, int length) native; |
| - void insertRange(int start, int length, [E initialValue]) native; |
| + void removeRange(int start, int length) native "this.splice(start, length);"; |
| + |
| + void insertRange(int start, int length, [E initialValue]) native |
| + """ |
| + // Splice in the values with a minimum of array allocations. |
| + var args = new Array(length + 2); |
| + args[0] = start; |
| + args[1] = 0; |
| + for (var i = 0; i < length; i++) args[i + 2] = initialValue; |
|
nweiz
2011/11/28 22:50:45
Are single-line loops supported by the styleguide?
Jennifer Messerly
2011/11/28 23:08:13
you should be able to surround this with an if:
Bob Nystrom
2011/11/29 02:44:08
Oops, you're right. Fixed.
|
| + this.splice.apply(this, args); |
| + """; |
| // Collection<E> members: |
| void forEach(void f(E element)) native; |