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

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]) {
76 // length of 0 prevails and should not throw exceptions.
77 if (length == 0)
Jennifer Messerly 2012/01/05 17:59:33 style nit: we generally put these on one line, or
dominich 2012/01/05 18:19:57 Done.
78 return;
79
80 if (length < 0)
81 throw new IllegalArgumentException('length is negative in setRange');
82
83 if (start < 0)
84 throw new IndexOutOfRangeException(start);
85 if (start + length > this.length)
86 throw new IndexOutOfRangeException(start + length);
87 startFrom = (startFrom == null ? 0 : startFrom);
88 if (startFrom < 0)
89 throw new IndexOutOfRangeException(startFrom);
90 if (startFrom + length > from.length)
91 throw new IndexOutOfRangeException(startFrom + length);
92
93 for (var i = 0; i < length; ++i)
94 this[start + i] = from[startFrom + i];
95 }
96
76 void removeRange(int start, int length) native "this.splice(start, length);"; 97 void removeRange(int start, int length) native "this.splice(start, length);";
77 98
78 void insertRange(int start, int length, [E initialValue]) native 99 void insertRange(int start, int length, [E initialValue]) native
79 """ 100 """
80 // Splice in the values with a minimum of array allocations. 101 // Splice in the values with a minimum of array allocations.
81 var args = new Array(length + 2); 102 var args = new Array(length + 2);
82 args[0] = start; 103 args[0] = start;
83 args[1] = 0; 104 args[1] = 0;
84 for (var i = 0; i < length; i++) { 105 for (var i = 0; i < length; i++) {
85 args[i + 2] = initialValue; 106 args[i + 2] = initialValue;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } else if (isNaN()) { 468 } else if (isNaN()) {
448 if (other.isNaN()) { 469 if (other.isNaN()) {
449 return 0; 470 return 0;
450 } 471 }
451 return 1; 472 return 1;
452 } else { 473 } else {
453 return -1; 474 return -1;
454 } 475 }
455 } 476 }
456 } 477 }
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