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

Unified Diff: sdk/lib/collection/queue.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 10 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
Index: sdk/lib/collection/queue.dart
diff --git a/sdk/lib/collection/queue.dart b/sdk/lib/collection/queue.dart
index 13ec536544a9b02b94fa9c5a2ebeedf51329a1cc..0da66b5607ebfba71e02b05a7fe2c1c22e104ab3 100644
--- a/sdk/lib/collection/queue.dart
+++ b/sdk/lib/collection/queue.dart
@@ -350,7 +350,7 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
initialCapacity = _nextPowerOf2(initialCapacity);
}
assert(_isPowerOf2(initialCapacity));
- _table = new List<E>.fixedLength(initialCapacity);
+ _table = new List<E>(initialCapacity);
}
/**
@@ -409,8 +409,13 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
return _table[(_head + index) & (_table.length - 1)];
}
- List<E> toList() {
- List<E> list = new List<E>(length);
+ List<E> toList({ bool growable: false }) {
+ List<E> list;
+ if (growable) {
+ list = new List<E>()..length = length;
+ } else {
+ list = new List<E>(length);
+ }
_writeToList(list);
return list;
}
@@ -629,7 +634,7 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
* Grow the table when full.
*/
void _grow() {
- List<E> newTable = new List<E>.fixedLength(_table.length * 2);
+ List<E> newTable = new List<E>(_table.length * 2);
int split = _table.length - _head;
newTable.setRange(0, split, _table, _head);
newTable.setRange(split, _head, _table, 0);
@@ -656,7 +661,7 @@ class ListQueue<E> extends Collection<E> implements Queue<E>{
void _preGrow(int newElementCount) {
assert(newElementCount >= length);
int newCapacity = _nextPowerOf2(newElementCount);
- List<E> newTable = new List<E>.fixedLength(newCapacity);
+ List<E> newTable = new List<E>(newCapacity);
_tail = _writeToList(newTable);
_table = newTable;
_head = 0;

Powered by Google App Engine
This is Rietveld 408576698