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

Side by Side Diff: runtime/lib/byte_array.dart

Issue 11098065: Fix bug in ByteArray.subByteArray implementation for omitted length. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 patch class Int8List { 5 patch class Int8List {
6 /* patch */ factory Int8List(int length) { 6 /* patch */ factory Int8List(int length) {
7 return new _Int8Array(length); 7 return new _Int8Array(length);
8 } 8 }
9 9
10 /* patch */ factory Int8List.view(ByteArray array, 10 /* patch */ factory Int8List.view(ByteArray array,
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 class _ByteArrayView implements ByteArray { 1506 class _ByteArrayView implements ByteArray {
1507 _ByteArrayView(this._array, this._offset, this._length) { 1507 _ByteArrayView(this._array, this._offset, this._length) {
1508 _rangeCheck(_array.lengthInBytes(), _offset, _length); 1508 _rangeCheck(_array.lengthInBytes(), _offset, _length);
1509 } 1509 }
1510 1510
1511 int lengthInBytes() { 1511 int lengthInBytes() {
1512 return _length; 1512 return _length;
1513 } 1513 }
1514 1514
1515 ByteArray subByteArray([int start = 0, int length]) { 1515 ByteArray subByteArray([int start = 0, int length]) {
1516 if (start is! int) throw new ArgumentError("start is not an int");
1516 if (length === null) { 1517 if (length === null) {
karlklose 2012/10/11 08:18:18 Use ?length here?
1517 length = this.lengthInBytes(); 1518 length = this.lengthInBytes() - start;
1519 } else if (length is! int) {
1520 throw new ArgumentError("length is not an int");
1518 } 1521 }
1519 return new _ByteArrayView(_array, _offset + start, length); 1522 return new _ByteArrayView(_array, _offset + start, length);
1520 } 1523 }
1521 1524
1522 int getInt8(int byteOffset) { 1525 int getInt8(int byteOffset) {
1523 return _array._getInt8(_offset + byteOffset); 1526 return _array._getInt8(_offset + byteOffset);
1524 } 1527 }
1525 int setInt8(int byteOffset, int value) { 1528 int setInt8(int byteOffset, int value) {
1526 return _array._setInt8(_offset + byteOffset, value); 1529 return _array._setInt8(_offset + byteOffset, value);
1527 } 1530 }
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 } 2409 }
2407 _rangeCheck(this.length, start, length); 2410 _rangeCheck(this.length, start, length);
2408 return _array.subByteArray(_offset + start, length); 2411 return _array.subByteArray(_offset + start, length);
2409 } 2412 }
2410 2413
2411 static const int _BYTES_PER_ELEMENT = 8; 2414 static const int _BYTES_PER_ELEMENT = 8;
2412 final ByteArray _array; 2415 final ByteArray _array;
2413 final int _offset; 2416 final int _offset;
2414 final int _length; 2417 final int _length;
2415 } 2418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698