Commit 3654b6f7 authored by Johannes Braun's avatar Johannes Braun

Remove std::find_if in huffman code generation as the chars have a fixed sorting.

parent 39557ac1
......@@ -67,11 +67,11 @@ namespace glshader::process::compress::huffman
std::array<code, 256> generate_codes(const std::vector<node>& tree, const uint32_t leaf_nodes)
{
std::array<code, 256> codes{ 0 };
for (int i=0; i<256; ++i)
for (int i=0, ch = 0; i<256; ++i)
{
if (const auto it = std::find_if(tree.begin(), tree.begin() + leaf_nodes, [i](const node& n) { return n.val == uint8_t(i); }); it != tree.end())
if (histogram[i]>0)
{
const node* n = &*it;
const node* n = &tree[ch++];
codes[i].signature.clear();
codes[i].length = 0;
auto ins_it = codes[i].signature.end();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment