MCPcopy Create free account
hub / github.com/TruthHun/BookStack / send_tree

Function send_tree

static/word2md/mammoth.browser.js:23172–23236  ·  view source on GitHub ↗
(s, tree, max_code)

Source from the content-addressed store, hash-verified

23170 * bl_tree.
23171 */
23172function send_tree(s, tree, max_code)
23173// deflate_state *s;
23174// ct_data *tree; /* the tree to be scanned */
23175// int max_code; /* and its largest code of non zero frequency */
23176{
23177 var n; /* iterates over all tree elements */
23178 var prevlen = -1; /* last emitted length */
23179 var curlen; /* length of current code */
23180
23181 var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */
23182
23183 var count = 0; /* repeat count of the current code */
23184 var max_count = 7; /* max repeat count */
23185 var min_count = 4; /* min repeat count */
23186
23187 /* tree[max_code+1].Len = -1; */ /* guard already set */
23188 if (nextlen === 0) {
23189 max_count = 138;
23190 min_count = 3;
23191 }
23192
23193 for (n = 0; n <= max_code; n++) {
23194 curlen = nextlen;
23195 nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;
23196
23197 if (++count < max_count && curlen === nextlen) {
23198 continue;
23199
23200 } else if (count < min_count) {
23201 do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);
23202
23203 } else if (curlen !== 0) {
23204 if (curlen !== prevlen) {
23205 send_code(s, curlen, s.bl_tree);
23206 count--;
23207 }
23208 //Assert(count >= 3 && count <= 6, " 3_6?");
23209 send_code(s, REP_3_6, s.bl_tree);
23210 send_bits(s, count - 3, 2);
23211
23212 } else if (count <= 10) {
23213 send_code(s, REPZ_3_10, s.bl_tree);
23214 send_bits(s, count - 3, 3);
23215
23216 } else {
23217 send_code(s, REPZ_11_138, s.bl_tree);
23218 send_bits(s, count - 11, 7);
23219 }
23220
23221 count = 0;
23222 prevlen = curlen;
23223 if (nextlen === 0) {
23224 max_count = 138;
23225 min_count = 3;
23226
23227 } else if (curlen === nextlen) {
23228 max_count = 6;
23229 min_count = 3;

Callers 1

send_all_treesFunction · 0.70

Calls 2

send_codeFunction · 0.70
send_bitsFunction · 0.70

Tested by

no test coverage detected