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

Unified Diff: runtime/lib/byte_array.dart

Issue 12817003: Change getRange to sublist. Make getRange deprecated. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 9 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: runtime/lib/byte_array.dart
diff --git a/runtime/lib/byte_array.dart b/runtime/lib/byte_array.dart
index 38a90f1453e19db9b2b1d0f0d50e78cb7698a0ee..d2e1ec0ebd48c7bab33549195697cfcfa010e81c 100644
--- a/runtime/lib/byte_array.dart
+++ b/runtime/lib/byte_array.dart
@@ -556,13 +556,17 @@ class _Int8Array extends _ByteArrayBase implements Int8List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Int8Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -620,13 +624,17 @@ class _Uint8Array extends _ByteArrayBase implements Uint8List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Uint8Array || from is _ExternalUint8Array ||
from is _Uint8ClampedArray || from is _ExternalUint8ClampedArray) {
@@ -686,13 +694,17 @@ class _Uint8ClampedArray extends _ByteArrayBase implements Uint8ClampedList {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Uint8Array || from is _ExternalUint8Array ||
from is _Uint8ClampedArray || from is _ExternalUint8ClampedArray) {
@@ -751,13 +763,17 @@ class _Int16Array extends _ByteArrayBase implements Int16List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Int16Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -815,13 +831,17 @@ class _Uint16Array extends _ByteArrayBase implements Uint16List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Uint16Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -879,13 +899,17 @@ class _Int32Array extends _ByteArrayBase implements Int32List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Int32Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -944,13 +968,17 @@ class _Uint32Array extends _ByteArrayBase implements Uint32List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Uint32Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1008,13 +1036,17 @@ class _Int64Array extends _ByteArrayBase implements Int64List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Int64Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1072,13 +1104,17 @@ class _Uint64Array extends _ByteArrayBase implements Uint64List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _Uint64Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1136,13 +1172,18 @@ class _Float32Array extends _ByteArrayBase implements Float32List {
return new _ByteArrayIterator<double>(this);
}
- List<double> getRange(int start, int length) {
+ List<double> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<double> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<double> getRange(int start, int length) =>
+ sublist(start, start + length);
+
void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
if (from is _Float32Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1200,13 +1241,18 @@ class _Float64Array extends _ByteArrayBase implements Float64List {
return new _ByteArrayIterator<double>(this);
}
- List<double> getRange(int start, int length) {
+ List<double> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<double> result = _new(length);
result.setRange(0, length, this, start);
return result;
}
+ List<double> getRange(int start, int length) =>
+ sublist(start, start + length);
+
void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
if (from is _Float64Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1253,13 +1299,17 @@ class _ExternalInt8Array extends _ByteArrayBase implements Int8List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int8List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalInt8Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1304,13 +1354,17 @@ class _ExternalUint8Array extends _ByteArrayBase implements Uint8List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint8List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalUint8Array || from is _Uint8Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1356,13 +1410,17 @@ class _ExternalUint8ClampedArray
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint8ClampedList(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalUint8ClampedArray || from is _Uint8ClampedArray) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1407,13 +1465,17 @@ class _ExternalInt16Array extends _ByteArrayBase implements Int16List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int16List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalInt16Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1458,13 +1520,17 @@ class _ExternalUint16Array extends _ByteArrayBase implements Uint16List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint16List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalUint16Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1511,13 +1577,17 @@ class _ExternalInt32Array extends _ByteArrayBase implements Int32List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int32List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalInt32Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1564,13 +1634,17 @@ class _ExternalUint32Array extends _ByteArrayBase implements Uint32List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint32List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalUint32Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1617,13 +1691,17 @@ class _ExternalInt64Array extends _ByteArrayBase implements Int64List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int64List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalInt64Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1670,13 +1748,17 @@ class _ExternalUint64Array extends _ByteArrayBase implements Uint64List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint64List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
if (from is _ExternalUint64Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1723,13 +1805,18 @@ class _ExternalFloat32Array extends _ByteArrayBase implements Float32List {
return new _ByteArrayIterator<double>(this);
}
- List<double> getRange(int start, int length) {
+ List<double> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<double> result = new Float32List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<double> getRange(int start, int length) =>
+ sublist(start, start + length);
+
void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
if (from is _ExternalFloat32Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -1776,13 +1863,18 @@ class _ExternalFloat64Array extends _ByteArrayBase implements Float64List {
return new _ByteArrayIterator<double>(this);
}
- List<double> getRange(int start, int length) {
+ List<double> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<double> result = new Float64List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<double> getRange(int start, int length) =>
+ sublist(start, start + length);
+
void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
if (from is _ExternalFloat64Array) {
_setRange(start * _BYTES_PER_ELEMENT,
@@ -2110,13 +2202,17 @@ class _Int8ArrayView extends _ByteArrayViewBase implements Int8List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int8List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2174,13 +2270,17 @@ class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint8List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2238,13 +2338,17 @@ class _Int16ArrayView extends _ByteArrayViewBase implements Int16List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int16List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2302,13 +2406,17 @@ class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint16List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2366,13 +2474,17 @@ class _Int32ArrayView extends _ByteArrayViewBase implements Int32List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int32List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2430,13 +2542,17 @@ class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint32List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2494,13 +2610,17 @@ class _Int64ArrayView extends _ByteArrayViewBase implements Int64List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Int64List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2558,13 +2678,17 @@ class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List {
return new _ByteArrayIterator<int>(this);
}
- List<int> getRange(int start, int length) {
+ List<int> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<int> result = new Uint64List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<int> getRange(int start, int length) => sublist(start, start + length);
+
void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2622,13 +2746,18 @@ class _Float32ArrayView extends _ByteArrayViewBase implements Float32List {
return new _ByteArrayIterator<double>(this);
}
- List<double> getRange(int start, int length) {
+ List<double> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<double> result = new Float32List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<double> getRange(int start, int length) =>
+ sublist(start, start + length);
+
void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -2686,13 +2815,18 @@ class _Float64ArrayView extends _ByteArrayViewBase implements Float64List {
return new _ByteArrayIterator<double>(this);
}
- List<double> getRange(int start, int length) {
+ List<double> sublist(int start, [int end]) {
+ if (end == null) end = this.length;
+ int length = end - start;
_rangeCheck(this.length, start, length);
List<double> result = new Float64List(length);
result.setRange(0, length, this, start);
return result;
}
+ List<double> getRange(int start, int length) =>
+ sublist(start, start + length);
+
void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}

Powered by Google App Engine
This is Rietveld 408576698