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

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

Issue 18115002: Make writes consistent across socket and file synchronous/asynchronus writes in terms of truncation… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/lib/io_patch.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/common.dart
===================================================================
--- sdk/lib/io/common.dart (revision 24619)
+++ sdk/lib/io/common.dart (working copy)
@@ -97,23 +97,12 @@
}
// 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
+// Only Int8List and Uint8List Lists are serialized directly.
+// All other lists are first copied into a Uint8List. This has the added
// benefit that it is faster to access from the C code as well.
-_BufferAndStart _ensureFastAndSerializableData(
+_BufferAndStart _ensureFastAndSerializableByteData(
List buffer, int start, int end) {
- if (buffer is Uint8List ||
- buffer is Int8List ||
- buffer is Uint16List ||
- buffer is Int16List ||
- buffer is Uint32List ||
- buffer is Int32List ||
- buffer is Uint64List ||
- buffer is Int64List ||
- buffer is ByteData ||
- buffer is Float32List ||
- buffer is Float64List ||
- _BufferUtils._isBuiltinList(buffer)) {
+ if (buffer is Uint8List || buffer is Int8List) {
return new _BufferAndStart(buffer, start);
}
int length = end - start;
@@ -131,37 +120,6 @@
}
-_BufferAndStart _ensureFastAndSerializableByteData(
- List buffer, int start, int end) {
- if (buffer is Uint8List) {
- return new _BufferAndStart(buffer, start);
- }
- 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 ||
- value < 0 || 255 < value) {
- throw new ArgumentError(
- "List element is not a byte value (value $value at index $j)");
- }
- newBuffer[i] = value;
- j++;
- }
- return new _BufferAndStart(newBuffer, 0);
-}
-
-
-// TODO(ager): The only reason for the class here is that
-// we cannot patch a top-level function.
-class _BufferUtils {
- // Check if a List is a builtin VM List type. Returns true
- // if the List is a builtin VM List type and false if it is
- // a user defined List type.
- external static bool _isBuiltinList(List buffer);
-}
-
class _IOCrypto {
external static Uint8List getRandomBytes(int count);
}
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698