@@ -694,6 +694,7 @@ impl<W: Write> Writer<W> {
694
694
let adaptive_method = self . options . adaptive_filter ;
695
695
696
696
let zlib_encoded = match self . info . compression {
697
+ Compression :: None => self . stored_only_compressor ( data, in_len) ?,
697
698
Compression :: Fast => {
698
699
let mut compressor = fdeflate:: Compressor :: new ( std:: io:: Cursor :: new ( Vec :: new ( ) ) ) ?;
699
700
@@ -724,13 +725,7 @@ impl<W: Write> Writer<W> {
724
725
// requested by the user. Doing filtering again would only add performance
725
726
// cost for both encoding and subsequent decoding, without improving the
726
727
// compression ratio.
727
- let mut compressor =
728
- fdeflate:: StoredOnlyCompressor :: new ( std:: io:: Cursor :: new ( Vec :: new ( ) ) ) ?;
729
- for line in data. chunks ( in_len) {
730
- compressor. write_data ( & [ 0 ] ) ?;
731
- compressor. write_data ( line) ?;
732
- }
733
- compressor. finish ( ) ?. into_inner ( )
728
+ self . stored_only_compressor ( data, in_len) ?
734
729
} else {
735
730
compressed
736
731
}
@@ -817,6 +812,15 @@ impl<W: Write> Writer<W> {
817
812
Ok ( ( ) )
818
813
}
819
814
815
+ fn stored_only_compressor ( & self , data : & [ u8 ] , in_len : usize ) -> Result < Vec < u8 > > {
816
+ let mut compressor = fdeflate:: StoredOnlyCompressor :: new ( std:: io:: Cursor :: new ( Vec :: new ( ) ) ) ?;
817
+ for line in data. chunks ( in_len) {
818
+ compressor. write_data ( & [ 0 ] ) ?;
819
+ compressor. write_data ( line) ?;
820
+ }
821
+ Ok ( compressor. finish ( ) ?. into_inner ( ) )
822
+ }
823
+
820
824
/// Set the used filter type for the following frames.
821
825
///
822
826
/// The default filter is [`FilterType::Sub`] which provides a basic prediction algorithm for
@@ -1706,6 +1710,7 @@ impl Compression {
1706
1710
Compression :: Huffman => flate2:: Compression :: none ( ) ,
1707
1711
#[ allow( deprecated) ]
1708
1712
Compression :: Rle => flate2:: Compression :: none ( ) ,
1713
+ Compression :: None => flate2:: Compression :: none ( ) ,
1709
1714
}
1710
1715
}
1711
1716
}
0 commit comments