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

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
Index: sdk/lib/io/common.dart
===================================================================
--- sdk/lib/io/common.dart (revision 24537)
+++ sdk/lib/io/common.dart (working copy)
@@ -97,43 +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(
- 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)) {
- 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) {
- throw new ArgumentError("List element is not an integer at index $j");
- }
- newBuffer[i] = value;
- j++;
- }
- return new _BufferAndStart(newBuffer, 0);
-}
-
-
_BufferAndStart _ensureFastAndSerializableByteData(
List buffer, int start, int end) {
- if (buffer is Uint8List) {
+ if (buffer is Uint8List || buffer is Int8List) {
return new _BufferAndStart(buffer, start);
}
int length = end - start;
@@ -153,15 +122,6 @@
}
-// 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);
}

Powered by Google App Engine
This is Rietveld 408576698