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

Unified Diff: pkg/barback/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/internal_asset.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/utils.dart
diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart
index d180137a69544a64035c0da567797df28f426949..ad97460c54facd74633c1d944eb7fc8c35002f98 100644
--- a/pkg/barback/lib/src/utils.dart
+++ b/pkg/barback/lib/src/utils.dart
@@ -5,6 +5,7 @@
library barback.utils;
import 'dart:async';
+import 'dart:typed_data';
/// A pair of values.
class Pair<E, F> {
@@ -79,6 +80,15 @@ String byteToHex(int byte) {
return DIGITS[(byte ~/ 16) % 16] + DIGITS[byte % 16];
}
+/// 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) return new Uint8List.view(input.buffer);
+ return new Uint8List.fromList(input);
+}
+
/// Group the elements in [iter] by the value returned by [fn].
///
/// This returns a map whose keys are the return values of [fn] and whose values
« no previous file with comments | « pkg/barback/lib/src/internal_asset.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698