function deflate_fast(s, flush) {
  var hash_head; /* head of the hash chain */
  var bflush; /* set if current block must be flushed */

  for (;;) {
    /* Make sure that we always have enough lookahead, except
     * at the end of the input file. We need MAX_MATCH bytes
     * for the next match, plus MIN_MATCH bytes to insert the
     * string following the next match.
     */
    if (s.lookahead < MIN_LOOKAHEAD) {
      fill_window(s);
      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$1) {
        return BS_NEED_MORE;
      }
      if (s.lookahead === 0) {
        break; /* flush the current block */
      }
    }

    /* Insert the string window[strstart .. strstart+2] in the
     * dictionary, and set hash_head to the head of the hash chain:
     */
    hash_head = 0 /*NIL*/ ;
    if (s.lookahead >= MIN_MATCH) {
      /*** INSERT_STRING(s, s.strstart, hash_head); ***/
      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
      s.head[s.ins_h] = s.strstart;
      /***/
    }

    /* Find the longest match, discarding those <= prev_length.
     * At this point we have always match_length < MIN_MATCH
     */
    if (hash_head !== 0 /*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {
      /* To simplify the code, we prevent matches with the string
       * of window index 0 (in particular we have to avoid a match
       * of the string with itself at the start of the input file).
       */
      s.match_length = longest_match(s, hash_head);
      /* longest_match() sets match_start */
    }
    if (s.match_length >= MIN_MATCH) {
      // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only

      /*** _tr_tally_dist(s, s.strstart - s.match_start,
                     s.match_length - MIN_MATCH, bflush); ***/
      bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);

      s.lookahead -= s.match_length;

      /* Insert new strings in the hash table only if the match length
       * is not too large. This saves time but degrades compression.
       */
      if (s.match_length <= s.max_lazy_match /*max_insert_length*/ && s.lookahead >= MIN_MATCH) {
        s.match_length--; /* string at strstart already in table */
        do {
          s.strstart++;
          /*** INSERT_STRING(s, s.strstart, hash_head); ***/
          s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
          s.head[s.ins_h] = s.strstart;
          /***/
          /* strstart never exceeds WSIZE-MAX_MATCH, so there are
           * always MIN_MATCH bytes ahead.
           */
        } while (--s.match_length !== 0);
        s.strstart++;
      } else {
        s.strstart += s.match_length;
        s.match_length = 0;
        s.ins_h = s.window[s.strstart];
        /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
        s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;

        //#if MIN_MATCH != 3
        //                Call UPDATE_HASH() MIN_MATCH-3 more times
        //#endif
        /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
         * matter since it will be recomputed at next deflate call.
         */
      }
    } else {
      /* No match, output a literal byte */
      //Tracevv((stderr,"%c", s.window[s.strstart]));
      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
      bflush = _tr_tally(s, 0, s.window[s.strstart]);

      s.lookahead--;
      s.strstart++;
    }
    if (bflush) {
      /*** FLUSH_BLOCK(s, 0); ***/
      flush_block_only(s, false);
      if (s.strm.avail_out === 0) {
        return BS_NEED_MORE;
      }
      /***/
    }
  }
  s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);
  if (flush === Z_FINISH$1) {
    /*** FLUSH_BLOCK(s, 1); ***/
    flush_block_only(s, true);
    if (s.strm.avail_out === 0) {
      return BS_FINISH_STARTED;
    }
    /***/
    return BS_FINISH_DONE;
  }
  if (s.last_lit) {
    /*** FLUSH_BLOCK(s, 0); ***/
    flush_block_only(s, false);
    if (s.strm.avail_out === 0) {
      return BS_NEED_MORE;
    }
    /***/
  }
  return BS_BLOCK_DONE;
}
/* ===========================================================================
 * 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 .
function deflate_fast(s, flush) {
  var hash_head; 
  var bflush; 
  for (;;) {
    if (s.lookahead < MIN_LOOKAHEAD) {
      fill_window(s);
      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$1) {
        return BS_NEED_MORE;
      }
      if (s.lookahead === 0) {
        break; 
      }
    }
    hash_head = 0  ;
    if (s.lookahead >= MIN_MATCH) {
      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
      s.head[s.ins_h] = s.strstart;
    }
    if (hash_head !== 0  && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {
      s.match_length = longest_match(s, hash_head);
    }
    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--; 
        do {
          s.strstart++;
          s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
          s.head[s.ins_h] = s.strstart;
        } while (--s.match_length !== 0);
        s.strstart++;
      } else {
        s.strstart += s.match_length;
        s.match_length = 0;
        s.ins_h = s.window[s.strstart];
        s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;
      }
    } else {
      bflush = _tr_tally(s, 0, s.window[s.strstart]);
      s.lookahead--;
      s.strstart++;
    }
    if (bflush) {
      flush_block_only(s, false);
      if (s.strm.avail_out === 0) {
        return BS_NEED_MORE;
      }
    }
  }
  s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);
  if (flush === Z_FINISH$1) {
    flush_block_only(s, true);
    if (s.strm.avail_out === 0) {
      return BS_FINISH_STARTED;
    }
    return BS_FINISH_DONE;
  }
  if (s.last_lit) {
    flush_block_only(s, false);
    if (s.strm.avail_out === 0) {
      return BS_NEED_MORE;
    }
  }
  return BS_BLOCK_DONE;
}
function deflate_fast ( s , flush ) { var hash_head ; var bflush ; for ( ; ; ) { if ( s . lookahead < MIN_LOOKAHEAD ) { fill_window ( s ) ; if ( s . lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$1 ) { return BS_NEED_MORE ; } if ( s . lookahead === 0 ) { break ; } } hash_head = 0 ; if ( s . lookahead >= MIN_MATCH ) { s . ins_h = ( ( s . ins_h << s . hash_shift ) ^ s . window [ s . strstart + MIN_MATCH - 1 ] ) & s . hash_mask ; hash_head = s . prev [ s . strstart & s . w_mask ] = s . head [ s . ins_h ] ; s . head [ s . ins_h ] = s . strstart ; } if ( hash_head !== 0 && ( ( s . strstart - hash_head ) <= ( s . w_size - MIN_LOOKAHEAD ) ) ) { s . match_length = longest_match ( s , hash_head ) ; } 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 -- ; do { s . strstart ++ ; s . ins_h = ( ( s . ins_h << s . hash_shift ) ^ s . window [ s . strstart + MIN_MATCH - 1 ] ) & s . hash_mask ; hash_head = s . prev [ s . strstart & s . w_mask ] = s . head [ s . ins_h ] ; s . head [ s . ins_h ] = s . strstart ; } while ( -- s . match_length !== 0 ) ; s . strstart ++ ; } else { s . strstart += s . match_length ; s . match_length = 0 ; s . ins_h = s . window [ s . strstart ] ; s . ins_h = ( ( s . ins_h << s . hash_shift ) ^ s . window [ s . strstart + 1 ] ) & s . hash_mask ; } } else { bflush = _tr_tally ( s , 0 , s . window [ s . strstart ] ) ; s . lookahead -- ; s . strstart ++ ; } if ( bflush ) { flush_block_only ( s , false ) ; if ( s . strm . avail_out === 0 ) { return BS_NEED_MORE ; } } } s . insert = ( ( s . strstart < ( MIN_MATCH - 1 ) ) ? s . strstart : MIN_MATCH - 1 ) ; if ( flush === Z_FINISH$1 ) { flush_block_only ( s , true ) ; if ( s . strm . avail_out === 0 ) { return BS_FINISH_STARTED ; } return BS_FINISH_DONE ; } if ( s . last_lit ) { flush_block_only ( s , false ) ; if ( s . strm . avail_out === 0 ) { return BS_NEED_MORE ; } } return BS_BLOCK_DONE ; }
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 .
/* head of the hash chain */ /* set if current block must be flushed */ /* Make sure that we always have enough lookahead, except
     * at the end of the input file. We need MAX_MATCH bytes
     * for the next match, plus MIN_MATCH bytes to insert the
     * string following the next match.
     */ /* flush the current block */ /* Insert the string window[strstart .. strstart+2] in the
     * dictionary, and set hash_head to the head of the hash chain:
     */ /*NIL*/ /*** INSERT_STRING(s, s.strstart, hash_head); ***/ /***/ /* Find the longest match, discarding those <= prev_length.
     * At this point we have always match_length < MIN_MATCH
     */ /*NIL*/ /* To simplify the code, we prevent matches with the string
       * of window index 0 (in particular we have to avoid a match
       * of the string with itself at the start of the input file).
       */ /* longest_match() sets match_start */ // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only /*** _tr_tally_dist(s, s.strstart - s.match_start,
                     s.match_length - MIN_MATCH, bflush); ***/ /* Insert new strings in the hash table only if the match length
       * is not too large. This saves time but degrades compression.
       */ /*max_insert_length*/ /* string at strstart already in table */ /*** INSERT_STRING(s, s.strstart, hash_head); ***/ /***/ /* strstart never exceeds WSIZE-MAX_MATCH, so there are
           * always MIN_MATCH bytes ahead.
           */ /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */ //#if MIN_MATCH != 3 //                Call UPDATE_HASH() MIN_MATCH-3 more times //#endif /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
         * matter since it will be recomputed at next deflate call.
         */ /* No match, output a literal byte */ //Tracevv((stderr,"%c", s.window[s.strstart])); /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ /*** FLUSH_BLOCK(s, 0); ***/ /***/ /*** FLUSH_BLOCK(s, 1); ***/ /***/ /*** FLUSH_BLOCK(s, 0); ***/ /***/