MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / _treeCompress

Method _treeCompress

packages/alphatab/src/zip/HuffTools.ts:81–99  ·  view source on GitHub ↗
(t: Huffman)

Source from the content-addressed store, hash-verified

79 }
80
81 private static _treeCompress(t: Huffman): Huffman {
82 const d: number = HuffTools._treeDepth(t);
83 if (d === 0) {
84 return t;
85 }
86 if (d === 1) {
87 if (t instanceof NeedBit) {
88 return new NeedBit(HuffTools._treeCompress(t.left), HuffTools._treeCompress(t.right));
89 }
90 throw new FormatError('assert');
91 }
92 const size: number = 1 << d;
93 const table: Huffman[] = [];
94 for (let i: number = 0; i < size; i++) {
95 table.push(new Found(-1));
96 }
97 HuffTools._treeWalk(table, 0, 0, d, t);
98 return new NeedBits(d, table);
99 }
100
101 private static _treeWalk(table: Huffman[], p: number, cd: number, d: number, t: Huffman): void {
102 if (t instanceof NeedBit) {

Callers 2

makeMethod · 0.80
_treeWalkMethod · 0.80

Calls 3

_treeDepthMethod · 0.80
_treeWalkMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected