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

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

Issue 10703118: Use native copy between internal/external bytearrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | no next file » | 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) 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 /** 5 /**
6 * A random-access sequence of bytes that also provides random access to 6 * A random-access sequence of bytes that also provides random access to
7 * the fixed-width integers and floating point numbers represented by 7 * the fixed-width integers and floating point numbers represented by
8 * those bytes. Byte arrays may be used to pack and unpack data from 8 * those bytes. Byte arrays may be used to pack and unpack data from
9 * external sources (such as networks or files systems), and to process 9 * external sources (such as networks or files systems), and to process
10 * large quantities of numerical data more efficiently than would be possible 10 * large quantities of numerical data more efficiently than would be possible
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1097 }
1098 1098
1099 List<int> getRange(int start, int length) { 1099 List<int> getRange(int start, int length) {
1100 _rangeCheck(this.length, start, length); 1100 _rangeCheck(this.length, start, length);
1101 List<int> result = _new(length); 1101 List<int> result = _new(length);
1102 result.setRange(0, length, this, start); 1102 result.setRange(0, length, this, start);
1103 return result; 1103 return result;
1104 } 1104 }
1105 1105
1106 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1106 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1107 if (from is _Uint8Array) { 1107 if (from is _Uint8Array || from is _ExternalUint8Array) {
1108 _setRange(start * _BYTES_PER_ELEMENT, 1108 _setRange(start * _BYTES_PER_ELEMENT,
1109 length * _BYTES_PER_ELEMENT, 1109 length * _BYTES_PER_ELEMENT,
1110 from, 1110 from,
1111 startFrom * _BYTES_PER_ELEMENT); 1111 startFrom * _BYTES_PER_ELEMENT);
1112 } else { 1112 } else {
1113 Arrays.copy(from, startFrom, this, start, length); 1113 Arrays.copy(from, startFrom, this, start, length);
1114 } 1114 }
1115 } 1115 }
1116 1116
1117 String toString() { 1117 String toString() {
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 } 1703 }
1704 1704
1705 List<int> getRange(int start, int length) { 1705 List<int> getRange(int start, int length) {
1706 _rangeCheck(this.length, start, length); 1706 _rangeCheck(this.length, start, length);
1707 List<int> result = new Uint8List(length); 1707 List<int> result = new Uint8List(length);
1708 result.setRange(0, length, this, start); 1708 result.setRange(0, length, this, start);
1709 return result; 1709 return result;
1710 } 1710 }
1711 1711
1712 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1712 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1713 if (from is _ExternalUint8Array) { 1713 if (from is _ExternalUint8Array || from is _Uint8Array) {
1714 _setRange(start * _BYTES_PER_ELEMENT, 1714 _setRange(start * _BYTES_PER_ELEMENT,
1715 length * _BYTES_PER_ELEMENT, 1715 length * _BYTES_PER_ELEMENT,
1716 from, 1716 from,
1717 startFrom * _BYTES_PER_ELEMENT); 1717 startFrom * _BYTES_PER_ELEMENT);
1718 } else { 1718 } else {
1719 Arrays.copy(from, startFrom, this, start, length); 1719 Arrays.copy(from, startFrom, this, start, length);
1720 } 1720 }
1721 } 1721 }
1722 1722
1723 String toString() { 1723 String toString() {
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 } 3056 }
3057 _rangeCheck(this.length, start, length); 3057 _rangeCheck(this.length, start, length);
3058 return _array.subByteArray(_offset + start, length); 3058 return _array.subByteArray(_offset + start, length);
3059 } 3059 }
3060 3060
3061 static final int _BYTES_PER_ELEMENT = 8; 3061 static final int _BYTES_PER_ELEMENT = 8;
3062 final ByteArray _array; 3062 final ByteArray _array;
3063 final int _offset; 3063 final int _offset;
3064 final int _length; 3064 final int _length;
3065 } 3065 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698