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

Unified Diff: sdk/lib/io/common.dart

Issue 14018007: Rename RandomAccessFile.readList and RandomAccessFile.writeList to RandomAccessFile.readInto and Ra… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 7 years, 8 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/tools/mini_parser.dart ('k') | sdk/lib/io/file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/common.dart
diff --git a/sdk/lib/io/common.dart b/sdk/lib/io/common.dart
index c4ebbf8226658a241eaef0d791a32693545a41c4..9350ad68308d76336d96e31ba3264f62cd4e3c07 100644
--- a/sdk/lib/io/common.dart
+++ b/sdk/lib/io/common.dart
@@ -58,18 +58,18 @@ class OSError implements Error {
// Object for holding a buffer and an offset.
-class _BufferAndOffset {
- _BufferAndOffset(List this.buffer, int this.offset);
+class _BufferAndStart {
+ _BufferAndStart(List this.buffer, int this.start);
List buffer;
- int offset;
+ int start;
}
// Ensure that the input List can be serialized through a native port.
// Only builtin Lists can be serialized through. If user-defined Lists
// get here, the contents is copied to a Uint8List. This has the added
// benefit that it is faster to access from the C code as well.
-_BufferAndOffset _ensureFastAndSerializableBuffer(
- List buffer, int offset, int bytes) {
+_BufferAndStart _ensureFastAndSerializableBuffer(
+ List buffer, int start, int end) {
if (buffer is Uint8List ||
buffer is Int8List ||
buffer is Uint16List ||
@@ -82,11 +82,12 @@ _BufferAndOffset _ensureFastAndSerializableBuffer(
buffer is Float32List ||
buffer is Float64List ||
_BufferUtils._isBuiltinList(buffer)) {
- return new _BufferAndOffset(buffer, offset);
+ return new _BufferAndStart(buffer, start);
}
- var newBuffer = new Uint8List(bytes);
- int j = offset;
- for (int i = 0; i < bytes; i++) {
+ int length = end - start;
+ var newBuffer = new Uint8List(length);
+ int j = start;
+ for (int i = 0; i < length; i++) {
int value = buffer[j];
if (value is! int) {
throw new ArgumentError("List element is not an integer at index $j");
@@ -94,7 +95,7 @@ _BufferAndOffset _ensureFastAndSerializableBuffer(
newBuffer[i] = value;
j++;
}
- return new _BufferAndOffset(newBuffer, 0);
+ return new _BufferAndStart(newBuffer, 0);
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/tools/mini_parser.dart ('k') | sdk/lib/io/file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698