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

Unified Diff: runtime/lib/growable_array.dart

Issue 8676001: Implement type checking of list literals (issue 220). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | runtime/lib/lib_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/growable_array.dart
===================================================================
--- runtime/lib/growable_array.dart (revision 1805)
+++ runtime/lib/growable_array.dart (working copy)
@@ -47,7 +47,7 @@
if (start < 0 || start > this.length) {
throw new IndexOutOfRangeException(start);
}
- if (this.length + length >= backingArray.length) {
+ if (this.length + length > backingArray.length) {
grow(backingArray.length + length);
}
Arrays.copy(backingArray,
@@ -72,8 +72,10 @@
return list;
}
- // The length of this growable array. It is always less than the
- // length of the backing array.
+ // The length of this growable array. It is always less than or equal to the
+ // length of the backing array, which itself is always greater than 0, so that
+ // grow() does not have to check for a zero length backing array before
+ // doubling its size.
int _length;
GrowableObjectArray()
@@ -87,14 +89,6 @@
backingArray = new ObjectArray<T>(capacity);
}
- GrowableObjectArray._usingArray(List<T> array) {
- backingArray = array;
- _length = array.length;
- if (_length == 0) {
- grow(4);
- }
- }
-
factory GrowableObjectArray<T>.from(Collection<T> other) {
List<T> result = new GrowableObjectArray<T>();
result.addAll(other);
@@ -106,7 +100,7 @@
}
void set length(int new_length) {
- if (new_length >= backingArray.length) {
+ if (new_length > backingArray.length) {
grow(new_length);
} else {
for (int i = new_length; i < _length; i++) {
« no previous file with comments | « no previous file | runtime/lib/lib_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698