function _tr_tally(s, dist, lc)
//    deflate_state *s;
//    unsigned dist;  /* distance of matched string */
//    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
{
  //var out_length, in_length, dcode;

  s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;
  s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;

  s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
  s.last_lit++;

  if (dist === 0) {
    /* lc is the unmatched char */
    s.dyn_ltree[lc * 2] /*.Freq*/ ++;
  } else {
    s.matches++;
    /* Here, lc is the match length - MIN_MATCH */
    dist--; /* dist = match distance - 1 */
    //Assert((ush)dist < (ush)MAX_DIST(s) &&
    //       (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
    //       (ush)d_code(dist) < (ush)D_CODES,  "_tr_tally: bad match");

    s.dyn_ltree[(_length_code[lc] + LITERALS$1 + 1) * 2] /*.Freq*/ ++;
    s.dyn_dtree[d_code(dist) * 2] /*.Freq*/ ++;
  }

  // (!) This block is disabled in zlib defailts,
  // don't enable it for binary compatibility

  //#ifdef TRUNCATE_BLOCK
  //  /* Try to guess if it is profitable to stop the current block here */
  //  if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {
  //    /* Compute an upper bound for the compressed length */
  //    out_length = s.last_lit*8;
  //    in_length = s.strstart - s.block_start;
  //
  //    for (dcode = 0; dcode < D_CODES; dcode++) {
  //      out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);
  //    }
  //    out_length >>>= 3;
  //    //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
  //    //       s->last_lit, in_length, out_length,
  //    //       100L - out_length*100L/in_length));
  //    if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
  //      return true;
  //    }
  //  }
  //#endif

  return (s.last_lit === s.lit_bufsize - 1);
  /* We avoid equality with lit_bufsize because of wraparound at 64K
   * on 16 bit machines and because stored blocks are restricted to
   * 64K-1 bytes.
   */
}
/* ===========================================================================
 * Save the match info and tally the frequency counts. Return true if
 * the current block must be flushed.
 */
Save the match info and tally the frequency counts. Return true if
the current block must be flushed.
Save the match info and tally the frequency counts . Return true if the current block must be flushed .
function _tr_tally(s, dist, lc)
{
  s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;
  s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
  s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
  s.last_lit++;
  if (dist === 0) {
    s.dyn_ltree[lc * 2]  ++;
  } else {
    s.matches++;
    dist--; 
    s.dyn_ltree[(_length_code[lc] + LITERALS$1 + 1) * 2]  ++;
    s.dyn_dtree[d_code(dist) * 2]  ++;
  }
      for (dcode = 0; dcode < D_CODES; dcode++) {
        out_length += s.dyn_dtree[dcode*2] * (5 + extra_dbits[dcode]);
      }
      out_length >>>= 3;
      Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
             s->last_lit, in_length, out_length,
             100L - out_length*100L/in_length));
      if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
        return true;
      }
    }
  #endif
  return (s.last_lit === s.lit_bufsize - 1);
}
function _tr_tally ( s , dist , lc ) { s . pending_buf [ s . d_buf + s . last_lit * 2 ] = ( dist >>> 8 ) & 0xff ; s . pending_buf [ s . d_buf + s . last_lit * 2 + 1 ] = dist & 0xff ; s . pending_buf [ s . l_buf + s . last_lit ] = lc & 0xff ; s . last_lit ++ ; if ( dist === 0 ) { s . dyn_ltree [ lc * 2 ] ++ ; } else { s . matches ++ ; dist -- ; s . dyn_ltree [ ( _length_code [ lc ] + LITERALS$1 + 1 ) * 2 ] ++ ; s . dyn_dtree [ d_code ( dist ) * 2 ] ++ ; } return ( s . last_lit === s . lit_bufsize - 1 ) ; }
Save the match info and tally the frequency counts.
Save the match info and tally the frequency counts .
//    deflate_state *s; //    unsigned dist;  /* distance of matched string */ //    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */ //var out_length, in_length, dcode; /* lc is the unmatched char */ /*.Freq*/ /* Here, lc is the match length - MIN_MATCH */ /* dist = match distance - 1 */ //Assert((ush)dist < (ush)MAX_DIST(s) && //       (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && //       (ush)d_code(dist) < (ush)D_CODES,  "_tr_tally: bad match"); /*.Freq*/ /*.Freq*/ // (!) This block is disabled in zlib defailts, // don't enable it for binary compatibility //#ifdef TRUNCATE_BLOCK //  /* Try to guess if it is profitable to stop the current block here */ //  if ((s.last_lit & 0x1fff) === 0 && s.level > 2) { //    /* Compute an upper bound for the compressed length */ //    out_length = s.last_lit*8; //    in_length = s.strstart - s.block_start; // //    for (dcode = 0; dcode < D_CODES; dcode++) { //      out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]); //    } //    out_length >>>= 3; //    //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", //    //       s->last_lit, in_length, out_length, //    //       100L - out_length*100L/in_length)); //    if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) { //      return true; //    } //  } //#endif /* We avoid equality with lit_bufsize because of wraparound at 64K
   * on 16 bit machines and because stored blocks are restricted to
   * 64K-1 bytes.
   */