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

Unified Diff: pkg/http/lib/src/utils.dart

Issue 68103027: Serialize binary barback assets using typed arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « pkg/barback/lib/src/utils.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/utils.dart
diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart
index dd3547d54926e1c4ce7f09363084e58379405cd6..64c50c4269e0c0e9c6a09701c0f1ec7465811625 100644
--- a/pkg/http/lib/src/utils.dart
+++ b/pkg/http/lib/src/utils.dart
@@ -107,17 +107,13 @@ final RegExp _ASCII_ONLY = new RegExp(r"^[\x00-\x7F]+$");
/// characters.
bool isPlainAscii(String string) => _ASCII_ONLY.hasMatch(string);
-/// Converts [input] into a [Uint8List]. If [input] is a [TypedData], this just
-/// returns a view on [input].
+/// Converts [input] into a [Uint8List].
+///
+/// If [input] is a [TypedData], this just returns a view on [input].
Uint8List toUint8List(List<int> input) {
if (input is Uint8List) return input;
- if (input is TypedData) {
- // TODO(nweiz): remove this "as" check when issue 11080 is fixed.
- return new Uint8List.view((input as TypedData).buffer);
- }
- var output = new Uint8List(input.length);
- output.setRange(0, input.length, input);
- return output;
+ if (input is TypedData) return new Uint8List.view(input.buffer);
+ return new Uint8List.fromList(input);
}
/// If [stream] is already a [ByteStream], returns it. Otherwise, wraps it in a
« no previous file with comments | « pkg/barback/lib/src/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698