lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# Same as above, but achieves better compression. We use a lazy
# evaluation for matches: a match is finally adopted only if there is
# no better match at the next window position.
Same as above, but achieves better compression. We use a lazy
evaluation for matches: a match is finally adopted only if there is
no better match at the next window position.
Same as above but achieves better compression . We use a lazy evaluation for matches : a match is finally adopted only if there is no better match at the next window position .
def deflate_slow(s,flush)
    hash_head = ZNIL
    loop do
      if (s.lookahead < MIN_LOOKAHEAD)
        fill_window(s)
        if (s.lookahead < MIN_LOOKAHEAD) && (flush == Z_NO_FLUSH)
          return :need_more
        end
        break if s.lookahead == 0
      end
      if (s.lookahead >= MIN_MATCH)
        hash_head = INSERT_STRING(s, s.strstart, hash_head)
      end
      s.prev_length = s.match_length
      s.prev_match = s.match_start
      s.match_length = MIN_MATCH-1
      if (hash_head != ZNIL) && (s.prev_length < s.max_lazy_match) &&
       (s.strstart - hash_head <= (s.w_size-MIN_LOOKAHEAD))
        if (s.strategy != Z_HUFFMAN_ONLY && s.strategy != Z_RLE)
          s.match_length = longest_match(s, hash_head)
        elsif(s.strategy == Z_RLE && s.strstart - hash_head == 1)
          s.match_length = longest_match_fast(s, hash_head)
        end
        if (s.match_length <= 5) && ((s.strategy == Z_FILTERED) ||
             ((s.match_length == MIN_MATCH) &&
              (s.strstart - s.match_start > TOO_FAR)))
            s.match_length = MIN_MATCH-1
        end
      end
      if (s.prev_length >= MIN_MATCH) && (s.match_length <= s.prev_length)
        max_insert = s.strstart + s.lookahead - MIN_MATCH
        bflush = _tr_tally(s, s.strstart - 1 - s.prev_match,
                          s.prev_length - MIN_MATCH)
        s.lookahead -= s.prev_length-1
        s.prev_length -= 2
        loop do
          s.strstart+=1
          if (s.strstart <= max_insert)
            hash_head = INSERT_STRING(s, s.strstart, hash_head)
          end
          s.prev_length-=1
          break if s.prev_length == 0
        end
        s.match_available = false
        s.match_length = MIN_MATCH-1
        s.strstart+=1
        if (bflush)
          FLUSH_BLOCK_ONLY(s, false)
          if s.strm.avail_out == 0
            return :need_more
          end
        end
      elsif (s.match_available)
          bflush = _tr_tally(s, 0, s.window[s.strstart-1].ord)
          if bflush
            FLUSH_BLOCK_ONLY(s, false)
          end
          s.strstart+=1
          s.lookahead-=1
          if s.strm.avail_out == 0
            return :need_more
          end
      else
          s.match_available = true
          s.strstart+=1
          s.lookahead-=1
      end
    end
    if (s.match_available)
      _tr_tally(s, 0, s.window[s.strstart-1].ord)
      s.match_available = false
    end
    FLUSH_BLOCK_ONLY(s, flush == Z_FINISH)
    if s.strm.avail_out == 0
      if flush == Z_FINISH
        return :finish_started
      else
        return :need_more
      end
    end
    if flush == Z_FINISH
      return :finish_done
    else
      return :block_done
    end
  end
def deflate_slow ( s , flush ) hash_head = ZNIL loop do if ( s . lookahead < MIN_LOOKAHEAD ) fill_window ( s ) if ( s . lookahead < MIN_LOOKAHEAD ) && ( flush == Z_NO_FLUSH ) return :need_more end break if s . lookahead == 0 end if ( s . lookahead >= MIN_MATCH ) hash_head = INSERT_STRING ( s , s . strstart , hash_head ) end s . prev_length = s . match_length s . prev_match = s . match_start s . match_length = MIN_MATCH - 1 if ( hash_head != ZNIL ) && ( s . prev_length < s . max_lazy_match ) && ( s . strstart - hash_head <= ( s . w_size - MIN_LOOKAHEAD ) ) if ( s . strategy != Z_HUFFMAN_ONLY && s . strategy != Z_RLE ) s . match_length = longest_match ( s , hash_head ) elsif ( s . strategy == Z_RLE && s . strstart - hash_head == 1 ) s . match_length = longest_match_fast ( s , hash_head ) end if ( s . match_length <= 5 ) && ( ( s . strategy == Z_FILTERED ) || ( ( s . match_length == MIN_MATCH ) && ( s . strstart - s . match_start > TOO_FAR ) ) ) s . match_length = MIN_MATCH - 1 end end if ( s . prev_length >= MIN_MATCH ) && ( s . match_length <= s . prev_length ) max_insert = s . strstart + s . lookahead - MIN_MATCH bflush = _tr_tally ( s , s . strstart - 1 - s . prev_match , s . prev_length - MIN_MATCH ) s . lookahead -= s . prev_length - 1 s . prev_length -= 2 loop do s . strstart += 1 if ( s . strstart <= max_insert ) hash_head = INSERT_STRING ( s , s . strstart , hash_head ) end s . prev_length -= 1 break if s . prev_length == 0 end s . match_available = false s . match_length = MIN_MATCH - 1 s . strstart += 1 if ( bflush ) FLUSH_BLOCK_ONLY ( s , false ) if s . strm . avail_out == 0 return :need_more end end elsif ( s . match_available ) bflush = _tr_tally ( s , 0 , s . window [ s . strstart - 1 ] . ord ) if bflush FLUSH_BLOCK_ONLY ( s , false ) end s . strstart += 1 s . lookahead -= 1 if s . strm . avail_out == 0 return :need_more end else s . match_available = true s . strstart += 1 s . lookahead -= 1 end end if ( s . match_available ) _tr_tally ( s , 0 , s . window [ s . strstart - 1 ] . ord ) s . match_available = false end FLUSH_BLOCK_ONLY ( s , flush == Z_FINISH ) if s . strm . avail_out == 0 if flush == Z_FINISH return :finish_started else return :need_more end end if flush == Z_FINISH return :finish_done else return :block_done end end
Same as above, but achieves better compression.
Same as above but achieves better compression .
s
<not_specific>
flush
<not_specific>