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

Unified Diff: runtime/bin/file_impl.dart

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 11 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/bin/file_impl.dart
===================================================================
--- runtime/bin/file_impl.dart (revision 3621)
+++ runtime/bin/file_impl.dart (working copy)
@@ -19,10 +19,10 @@
}
List<int> _read(int bytesToRead) {
- List<int> result = new List<int>(bytesToRead);
+ List<int> result = new ByteArray(bytesToRead);
int bytesRead = _file.readListSync(result, 0, bytesToRead);
if (bytesRead < bytesToRead) {
- List<int> buffer = new List<int>(bytesRead);
+ List<int> buffer = new ByteArray(bytesRead);
buffer.copyFrom(result, 0, 0, bytesRead);
result = buffer;
}
@@ -175,7 +175,7 @@
port.toSendPort());
return;
}
- var buffer = new List(_bytes);
+ var buffer = new ByteArray(_bytes);
var result =
new _ReadListResult(_FileUtils.readList(_id, buffer, 0, _bytes),
buffer);
@@ -424,12 +424,14 @@
// When using the Dart C API access to ObjectArray by index is
// currently much faster. This function will make a copy of the
// supplied List to an ObjectArray if it isn't already.
- ObjectArray outBuffer;
+ List<int> outBuffer;
int outOffset = offset;
if (buffer is ObjectArray) {
outBuffer = buffer;
+ } else if (buffer is ByteArray) {
+ outBuffer = buffer;
} else {
- outBuffer = new ObjectArray(bytes);
+ outBuffer = new ByteArray(bytes);
outOffset = 0;
int j = offset;
for (int i = 0; i < bytes; i++) {

Powered by Google App Engine
This is Rietveld 408576698