Index: sdk/lib/io/common.dart |
diff --git a/sdk/lib/io/common.dart b/sdk/lib/io/common.dart |
index 31ce72b6c9232096c18104b1a907dc6bc4204972..5470cc23fa5945f05fb62f4beff4a8728ab35739 100644 |
--- a/sdk/lib/io/common.dart |
+++ b/sdk/lib/io/common.dart |
@@ -131,6 +131,28 @@ _BufferAndStart _ensureFastAndSerializableBuffer( |
} |
+_BufferAndStart _ensureFastAndSerializableByteBuffer( |
Anders Johnsen
2013/06/12 06:13:58
It's not a byte buffer but a view we returns, but
Søren Gjesse
2013/06/12 08:34:00
Done (just Data instead of TypedData).
|
+ 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 { |