From 822310eb43701ed25f5f9114b82565e2b5a138b8 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Tue, 18 Feb 2014 04:01:10 +0400 Subject: [PATCH] Removed float ops & added comments --- lib/zlib/deflate.js | 5 +++-- lib/zlib/trees.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/zlib/deflate.js b/lib/zlib/deflate.js index 32852f5..5ec531a 100644 --- a/lib/zlib/deflate.js +++ b/lib/zlib/deflate.js @@ -556,7 +556,7 @@ function deflate_fast(s, flush) { /* 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 && s.lookahead >= MIN_MATCH) { + 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++; @@ -1089,7 +1089,8 @@ function DeflateState() { * smaller than this value. This mechanism is used only for compression * levels >= 4. */ - this.max_insert_length = 0; + // That's alias to max_lazy_match, don't use directly + //this.max_insert_length = 0; /* Insert new strings in the hash table only if the match length is not * greater than this length. This saves time but degrades compression. * max_insert_length is used only for compression levels <= 3. diff --git a/lib/zlib/trees.js b/lib/zlib/trees.js index 2522125..e28f140 100644 --- a/lib/zlib/trees.js +++ b/lib/zlib/trees.js @@ -659,7 +659,7 @@ function build_tree(s, desc) /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ - for (n = Math.floor(s.heap_len / 2); n >= 1; n--) { pqdownheap(s, tree, n); } + for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); } /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. @@ -1126,7 +1126,7 @@ function _tr_tally(s, dist, lc) //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/2 && out_length < in_length/2) { + if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) { return true; } }