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

Unified Diff: sdk/lib/convert/latin1.dart

Issue 208693008: Speed up ASCII, LATIN1, UTF8 converters, for single-byte codeunits. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes. Created 6 years, 9 months 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 | « sdk/lib/convert/convert.dart ('k') | sdk/lib/convert/utf.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/convert/latin1.dart
diff --git a/sdk/lib/convert/latin1.dart b/sdk/lib/convert/latin1.dart
index 033f8dd6e5093730a8e635c1c753d011dc0bfc55..bfc12a7e8ec607c0151cada6fc1797756f353e31 100644
--- a/sdk/lib/convert/latin1.dart
+++ b/sdk/lib/convert/latin1.dart
@@ -125,13 +125,22 @@ class _Latin1DecoderSink extends ByteConversionSinkBase {
void _addSliceToSink(List<int> source, int start, int end, bool isLast) {
// If _sink was a UTF-16 conversion sink, just add the slice directly with
// _sink.addSlice(source, start, end, isLast).
- // The code below is an incredibly stupid workaround until a real
+ // The code below is an moderately stupid workaround until a real
// solution can be made.
- _sink.add(new String.fromCharCodes(source.getRange(start, end)));
+ if (start == 0 && end == source.length) {
+ _sink.add(new String.fromCharCodes(source));
+ } else {
+ _sink.add(new String.fromCharCodes(source.sublist(start, end)));
+ }
if (isLast) close();
}
void addSlice(List<int> source, int start, int end, bool isLast) {
+ // If Uint8List, just add dircetly.
+ if (source is Uint8List) {
+ _addSliceToSink(source, start, end, isLast);
+ return;
+ }
if (start < 0 || start > source.length) {
throw new RangeError.range(start, 0, source.length);
}
« no previous file with comments | « sdk/lib/convert/convert.dart ('k') | sdk/lib/convert/utf.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698