Skip to content

utf converter seems to be slow #22330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
floitschG opened this issue Feb 9, 2015 · 2 comments
Open

utf converter seems to be slow #22330

floitschG opened this issue Feb 9, 2015 · 2 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop dart2js-optimization type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@floitschG
Copy link
Contributor

According to http://stackoverflow.com/questions/28359949/how-to-convert-binary-data-to-utf8-string-after-dart2js utf8 encoding/decoding is slow in dart2js.

Load:


import 'dart:convert';
import 'package:archive/archive.dart';
import 'package:crypto/crypto.dart';

var base64 = CryptoUtils.base64StringToBytes(window.localStorage[storageName]);
var decompress = new GZipDecoder().decodeBytes(base64);
storage = JSON.decode(new Utf8Decoder().convert(decompress));


Save:


var g = JSON.encode(storage);
List<int> bz2 = new GZipEncoder().encode(new Utf8Encoder().convert(g));
window.localStorage[storageName] = CryptoUtils.bytesToBase64(bz2);


@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Mar 1, 2016
@rakudrama
Copy link
Member

Consider using TextEncoder / TextDecoder on browsers that support this operation.
It might still be necessary to fall back on the current implementation if there is a mismatch in error handling.

@rakudrama
Copy link
Member

3836c70 uses the browser's TextDecoder where it is available and the input does not contain any tricky situations.
Encoding is still slow.

@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop label Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop dart2js-optimization type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants