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

Side by Side Diff: sdk/lib/io/data_transformer.dart

Issue 1393013002: Ensure ZILB encoder handles all typed data lists correctly (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * Exposes ZLib options for input parameters. 8 * Exposes ZLib options for input parameters.
9 * 9 *
10 * See http://www.zlib.net/manual.html for more documentation. 10 * See http://www.zlib.net/manual.html for more documentation.
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 addSlice(data, 0, data.length, false); 481 addSlice(data, 0, data.length, false);
482 } 482 }
483 483
484 void addSlice(List<int> data, int start, int end, bool isLast) { 484 void addSlice(List<int> data, int start, int end, bool isLast) {
485 if (_closed) return; 485 if (_closed) return;
486 if (start < 0 || start > data.length) { 486 if (start < 0 || start > data.length) {
487 throw new ArgumentError("Invalid start position"); 487 throw new ArgumentError("Invalid start position");
488 } 488 }
489 if (end < 0 || end > data.length || end < start) { 489 if (end < 0 || end > data.length || end < start) {
490 throw new ArgumentError("Invalid end position"); 490 throw new ArgumentError("Invalid end position");
491 } 491 }
Lasse Reichstein Nielsen 2015/10/08 11:26:57 This could do with updating: if (end == null) th
492 try { 492 try {
493 _empty = false; 493 _empty = false;
494 _filter.process(data, start, end); 494 _BufferAndStart bufferAndStart =
Lasse Reichstein Nielsen 2015/10/08 11:26:57 Have you considered having _ensureFastAndSerializa
495 _ensureFastAndSerializableByteData(data, start, end);
496 _filter.process(bufferAndStart.buffer,
497 bufferAndStart.start,
498 end - (start - bufferAndStart.start));
495 var out; 499 var out;
496 while ((out = _filter.processed(flush: false)) != null) { 500 while ((out = _filter.processed(flush: false)) != null) {
497 _sink.add(out); 501 _sink.add(out);
498 } 502 }
499 } catch (e) { 503 } catch (e) {
500 _closed = true; 504 _closed = true;
501 throw e; 505 throw e;
Lasse Reichstein Nielsen 2015/10/08 11:26:57 Change "throw e" to "rethrow".
502 } 506 }
503 507
504 if (isLast) close(); 508 if (isLast) close();
505 } 509 }
506 510
507 void close() { 511 void close() {
508 if (_closed) return; 512 if (_closed) return;
509 // Be sure to send process an empty chunk of data. Without this, the empty 513 // Be sure to send process an empty chunk of data. Without this, the empty
510 // message would not have a GZip frame (if compressed with GZip). 514 // message would not have a GZip frame (if compressed with GZip).
511 if (_empty) _filter.process(const [], 0, 0); 515 if (_empty) _filter.process(const [], 0, 0);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 590 }
587 591
588 void _validateZLibStrategy(int strategy) { 592 void _validateZLibStrategy(int strategy) {
589 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, 593 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED,
590 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, 594 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE,
591 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; 595 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT];
592 if (strategies.indexOf(strategy) == -1) { 596 if (strategies.indexOf(strategy) == -1) {
593 throw new ArgumentError("Unsupported 'strategy'"); 597 throw new ArgumentError("Unsupported 'strategy'");
594 } 598 }
595 } 599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698