@@ -132,7 +132,7 @@ public bool Deflate(bool flush, bool finish)
132
132
#if DebugDeflation
133
133
if ( DeflaterConstants . DEBUGGING ) {
134
134
Console . WriteLine ( "window: [" + blockStart + "," + strstart + ","
135
- + lookahead + "], " + compressionFunction + "," + canFlush ) ;
135
+ + lookahead + "], " + compressionFunction + "," + canFlush ) ;
136
136
}
137
137
#endif
138
138
switch ( compressionFunction )
@@ -322,7 +322,7 @@ public void SetLevel(int level)
322
322
#if DebugDeflation
323
323
if ( DeflaterConstants . DEBUGGING ) {
324
324
Console . WriteLine ( "Change from " + compressionFunction + " to "
325
- + DeflaterConstants . COMPR_FUNC [ level ] ) ;
325
+ + DeflaterConstants . COMPR_FUNC [ level ] ) ;
326
326
}
327
327
#endif
328
328
switch ( compressionFunction ) {
@@ -422,12 +422,12 @@ int InsertString()
422
422
if ( DeflaterConstants . DEBUGGING )
423
423
{
424
424
if ( hash != ( ( ( window [ strstart ] << ( 2 * HASH_SHIFT ) ) ^
425
- ( window [ strstart + 1 ] << HASH_SHIFT ) ^
426
- ( window [ strstart + 2 ] ) ) & HASH_MASK ) ) {
425
+ ( window [ strstart + 1 ] << HASH_SHIFT ) ^
426
+ ( window [ strstart + 2 ] ) ) & HASH_MASK ) ) {
427
427
throw new SharpZipBaseException ( "hash inconsistent: " + hash + "/"
428
- + window [ strstart ] + ","
429
- + window [ strstart + 1 ] + ","
430
- + window [ strstart + 2 ] + "," + HASH_SHIFT ) ;
428
+ + window [ strstart ] + ","
429
+ + window [ strstart + 1 ] + ","
430
+ + window [ strstart + 2 ] + "," + HASH_SHIFT ) ;
431
431
}
432
432
}
433
433
#endif
@@ -637,13 +637,8 @@ bool DeflateFast(bool flush, bool finish)
637
637
}
638
638
#endif
639
639
640
- // This stops problems with fast/low compression and index out of range
641
- if ( huffman . TallyDist ( strstart - matchStart , matchLen ) ) {
642
- bool lastBlock = finish && lookahead == 0 ;
643
- huffman . FlushBlock ( window , blockStart , strstart - blockStart , lastBlock ) ;
644
- blockStart = strstart ;
645
- }
646
-
640
+ bool full = huffman . TallyDist ( strstart - matchStart , matchLen ) ;
641
+
647
642
lookahead -= matchLen ;
648
643
if ( matchLen <= max_lazy && lookahead >= MIN_MATCH ) {
649
644
while ( -- matchLen > 0 ) {
@@ -658,7 +653,9 @@ bool DeflateFast(bool flush, bool finish)
658
653
}
659
654
}
660
655
matchLen = MIN_MATCH - 1 ;
661
- continue ;
656
+ if ( ! full ) {
657
+ continue ;
658
+ }
662
659
} else {
663
660
// No match found
664
661
huffman . TallyLit ( window [ strstart ] & 0xff ) ;
@@ -736,8 +733,8 @@ bool DeflateSlow(bool flush, bool finish)
736
733
if ( DeflaterConstants . DEBUGGING )
737
734
{
738
735
for ( int i = 0 ; i < matchLen ; i ++ ) {
739
- if ( window [ strstart - 1 + i ] != window [ prevMatch + i ] )
740
- throw new SharpZipBaseException ( ) ;
736
+ if ( window [ strstart - 1 + i ] != window [ prevMatch + i ] )
737
+ throw new SharpZipBaseException ( ) ;
741
738
}
742
739
}
743
740
#endif
0 commit comments