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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/corelib/corelib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("dart:coreimpl"); 5 #library("dart:coreimpl");
6 6
7 #source("../../corelib/src/implementation/dual_pivot_quicksort.dart"); 7 #source("../../corelib/src/implementation/dual_pivot_quicksort.dart");
8 #source("../../corelib/src/implementation/duration_implementation.dart"); 8 #source("../../corelib/src/implementation/duration_implementation.dart");
9 #source("../../corelib/src/implementation/exceptions.dart"); 9 #source("../../corelib/src/implementation/exceptions.dart");
10 #source("../../corelib/src/implementation/future_implementation.dart"); 10 #source("../../corelib/src/implementation/future_implementation.dart");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 int lastIndexOf(E element, [int start]) native; 65 int lastIndexOf(E element, [int start]) native;
66 void clear() { length = 0; } 66 void clear() { length = 0; }
67 67
68 E removeLast() native "return this.pop();"; 68 E removeLast() native "return this.pop();";
69 69
70 E last() => this[this.length-1]; 70 E last() => this[this.length-1];
71 71
72 List<E> getRange(int start, int length) native 72 List<E> getRange(int start, int length) native
73 "return this.slice(start, start + length);"; 73 "return this.slice(start, start + length);";
74 74
75 void setRange(int start, int length, List<E> from, [int startFrom]) native; 75 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.
76 // length of 0 prevails and should not throw exceptions.
77 if (length == 0) return;
78 if (length < 0) throw new IllegalArgumentException('length is negative');
79
80 if (start < 0) throw new IndexOutOfRangeException(start);
81
82 int end = start + length;
83 if (end > this.length) throw new IndexOutOfRangeException(end);
84
85 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.
86 if (startFrom < 0) throw new IndexOutOfRangeException(startFrom);
87
88 int endFrom = startFrom + length;
89 if (endFrom > from.length) throw new IndexOutOfRangeException(endFrom);
90
91 for (var i = 0; i < length; ++i)
92 this[start + i] = from[startFrom + i];
93 }
94
76 void removeRange(int start, int length) native "this.splice(start, length);"; 95 void removeRange(int start, int length) native "this.splice(start, length);";
77 96
78 void insertRange(int start, int length, [E initialValue]) native 97 void insertRange(int start, int length, [E initialValue]) native
79 """ 98 """
80 // Splice in the values with a minimum of array allocations. 99 // Splice in the values with a minimum of array allocations.
81 var args = new Array(length + 2); 100 var args = new Array(length + 2);
82 args[0] = start; 101 args[0] = start;
83 args[1] = 0; 102 args[1] = 0;
84 for (var i = 0; i < length; i++) { 103 for (var i = 0; i < length; i++) {
85 args[i + 2] = initialValue; 104 args[i + 2] = initialValue;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } else if (isNaN()) { 466 } else if (isNaN()) {
448 if (other.isNaN()) { 467 if (other.isNaN()) {
449 return 0; 468 return 0;
450 } 469 }
451 return 1; 470 return 1;
452 } else { 471 } else {
453 return -1; 472 return -1;
454 } 473 }
455 } 474 }
456 } 475 }
OLDNEW
« 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