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

Unified Diff: pkg/barback/lib/src/internal_asset.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 | « no previous file | pkg/barback/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/internal_asset.dart
diff --git a/pkg/barback/lib/src/internal_asset.dart b/pkg/barback/lib/src/internal_asset.dart
index 85ce4dce6eb994ef217f8defc04f9a7f6ebe9c10..6b3c9fbe7cee3ebc6df8a0db9b9a43517828c5e1 100644
--- a/pkg/barback/lib/src/internal_asset.dart
+++ b/pkg/barback/lib/src/internal_asset.dart
@@ -7,6 +7,7 @@ library barback.internal_asset;
import 'dart:async';
import 'dart:convert';
import 'dart:io';
+import 'dart:typed_data';
import 'asset.dart';
import 'asset_id.dart';
@@ -19,16 +20,10 @@ import 'utils.dart';
Map serializeAsset(Asset asset) {
var id = serializeId(asset.id);
if (asset is BinaryAsset) {
- // If [_contents] is a custom subclass of List, it won't be serializable, so
- // we have to convert it to a built-in [List] first.
- // TODO(nweiz): Send a typed array if that works after issue 14703 is fixed.
- var contents = asset._contents.runtimeType == List ?
- asset._contents : asset._contents.toList();
-
return {
'type': 'binary',
'id': id,
- 'contents': contents
+ 'contents': asset._contents
};
} else if (asset is FileAsset) {
return {
@@ -72,9 +67,10 @@ Asset deserializeAsset(Map asset) {
class BinaryAsset implements Asset {
final AssetId id;
- final List<int> _contents;
+ final Uint8List _contents;
- BinaryAsset(this.id, this._contents);
+ BinaryAsset(this.id, List<int> contents)
+ : _contents = toUint8List(contents);
Future<String> readAsString({Encoding encoding}) {
if (encoding == null) encoding = UTF8;
« no previous file with comments | « no previous file | pkg/barback/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698