lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# Compress as much as possible from the input stream, return the current
# block state.
# This function does not perform lazy evaluation of matches and inserts
# new strings in the dictionary only for unmatched strings or for short
# matches. It is used only for the fast compression options.
Compress as much as possible from the input stream, return the current
block state.
This function does not perform lazy evaluation of matches and inserts
new strings in the dictionary only for unmatched strings or for short
matches. It is used only for the fast compression options.
Compress as much as possible from the input stream return the current block state . This function does not perform lazy evaluation of matches and inserts new strings in the dictionary only for unmatched strings or for short matches . It is used only for the fast compression options .
def deflate_fast(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
      if (hash_head != ZNIL) &&
       (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.srstart - hash_end == 1)
          s.match_length = longest_match_fast(s, hash_head)
        end
      end
      if (s.match_length >= MIN_MATCH)
        bflush = _tr_tally(s, s.strstart - s.match_start,
                        s.match_length - MIN_MATCH)
        s.lookahead -= s.match_length
        if (s.match_length <= s.max_lazy_match) && (s.lookahead >= MIN_MATCH)
          s.match_length -= 1
          loop do
            s.strstart += 1
            hash_head = INSERT_STRING(s, s.strstart, hash_head)
            s.match_length -= 1
            break if s.match_length == 0
          end
          s.strstart += 1
        else
          s.strstart += s.match_length
          s.match_length = 0
          s.ins_h = s.window[s.strstart].ord
          s.ins_h = (( s.ins_h << s.hash_shift) ^
                     s.window[s.strstart+1].ord) & s.hash_mask
        end
      else
        bflush = _tr_tally(s, 0, s.window[s.strstart].ord)
        s.lookahead-=1
        s.strstart+=1
      end
      if bflush
        FLUSH_BLOCK_ONLY(s, false)
        if s.strm.avail_out == 0
          return :need_more
        end
      end
    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_fast ( 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 if ( hash_head != ZNIL ) && ( 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 . srstart - hash_end == 1 ) s . match_length = longest_match_fast ( s , hash_head ) end end if ( s . match_length >= MIN_MATCH ) bflush = _tr_tally ( s , s . strstart - s . match_start , s . match_length - MIN_MATCH ) s . lookahead -= s . match_length if ( s . match_length <= s . max_lazy_match ) && ( s . lookahead >= MIN_MATCH ) s . match_length -= 1 loop do s . strstart += 1 hash_head = INSERT_STRING ( s , s . strstart , hash_head ) s . match_length -= 1 break if s . match_length == 0 end s . strstart += 1 else s . strstart += s . match_length s . match_length = 0 s . ins_h = s . window [ s . strstart ] . ord s . ins_h = ( ( s . ins_h << s . hash_shift ) ^ s . window [ s . strstart + 1 ] . ord ) & s . hash_mask end else bflush = _tr_tally ( s , 0 , s . window [ s . strstart ] . ord ) s . lookahead -= 1 s . strstart += 1 end if bflush FLUSH_BLOCK_ONLY ( s , false ) if s . strm . avail_out == 0 return :need_more end end 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
Compress as much as possible from the input stream, return the current
block state.
Compress as much as possible from the input stream return the current block state .
s
<not_specific>
flush
<not_specific>