Rename std/bzip2 num_nodes variable

This commit is contained in:
Nigel Tao committed 2022-06-10 14:06:27 +10:00
1 parent 8c33dd503b
commit 67aa63297c
2 files changed
+24 -24

No files matched your search

+9 -9
View File
@@ -25800,7 +25800,7 @@ wuffs_bzip2__decoder__build_huffman_tree(
uint32_t a_which) { uint32_t a_which) {
uint32_t v_code_length = 0; uint32_t v_code_length = 0;
uint32_t v_symbol_index = 0; uint32_t v_symbol_index = 0;
uint32_t v_num_nodes = 0; uint32_t v_num_branch_nodes = 0;
uint32_t v_stack_height = 0; uint32_t v_stack_height = 0;
uint32_t v_stack_values[21] = {0}; uint32_t v_stack_values[21] = {0};
uint32_t v_node_index = 0; uint32_t v_node_index = 0;
@@ -25808,7 +25808,7 @@ wuffs_bzip2__decoder__build_huffman_tree(
self->private_data.f_huffman_trees[a_which][0][0] = 0; self->private_data.f_huffman_trees[a_which][0][0] = 0;
self->private_data.f_huffman_trees[a_which][0][1] = 0; self->private_data.f_huffman_trees[a_which][0][1] = 0;
v_num_nodes = 1; v_num_branch_nodes = 1;
v_stack_height = 1; v_stack_height = 1;
v_stack_values[0] = 0; v_stack_values[0] = 0;
v_code_length = 1; v_code_length = 1;
@@ -25833,17 +25833,17 @@ wuffs_bzip2__decoder__build_huffman_tree(
} }
v_node_index = v_stack_values[(v_stack_height - 1)]; v_node_index = v_stack_values[(v_stack_height - 1)];
if (self->private_data.f_huffman_trees[a_which][v_node_index][0] == 0) { if (self->private_data.f_huffman_trees[a_which][v_node_index][0] == 0) {
self->private_data.f_huffman_trees[a_which][v_node_index][0] = ((uint16_t)(v_num_nodes)); self->private_data.f_huffman_trees[a_which][v_node_index][0] = ((uint16_t)(v_num_branch_nodes));
} else { } else {
self->private_data.f_huffman_trees[a_which][v_node_index][1] = ((uint16_t)(v_num_nodes)); self->private_data.f_huffman_trees[a_which][v_node_index][1] = ((uint16_t)(v_num_branch_nodes));
} }
if (v_num_nodes >= 257) { if (v_num_branch_nodes >= 257) {
return wuffs_base__make_status(wuffs_bzip2__error__bad_huffman_code_under_subscribed); return wuffs_base__make_status(wuffs_bzip2__error__bad_huffman_code_under_subscribed);
} }
v_stack_values[v_stack_height] = v_num_nodes; v_stack_values[v_stack_height] = v_num_branch_nodes;
self->private_data.f_huffman_trees[a_which][v_num_nodes][0] = 0; self->private_data.f_huffman_trees[a_which][v_num_branch_nodes][0] = 0;
self->private_data.f_huffman_trees[a_which][v_num_nodes][1] = 0; self->private_data.f_huffman_trees[a_which][v_num_branch_nodes][1] = 0;
v_num_nodes += 1; v_num_branch_nodes += 1;
v_stack_height += 1; v_stack_height += 1;
} }
label__2__break:; label__2__break:;
+15 -15
View File
@@ -589,18 +589,18 @@ pri func decoder.read_code_lengths?(src: base.io_reader) {
// height (here, 3) then it would pop the stack. Otherwise it would push new // height (here, 3) then it would pop the stack. Otherwise it would push new
// nodes onto the stack until the stack height matched that code length. // nodes onto the stack until the stack height matched that code length.
pri func decoder.build_huffman_tree!(which: base.u32[..= 5]) base.status { pri func decoder.build_huffman_tree!(which: base.u32[..= 5]) base.status {
var code_length : base.u32 var code_length : base.u32
var symbol_index : base.u32 var symbol_index : base.u32
var num_nodes : base.u32[..= 257] var num_branch_nodes : base.u32[..= 257]
var stack_height : base.u32[..= 21] var stack_height : base.u32[..= 21]
var stack_values : array[21] base.u32[..= 256] var stack_values : array[21] base.u32[..= 256]
var node_index : base.u32[..= 256] var node_index : base.u32[..= 256]
var leaf_value : base.u16 var leaf_value : base.u16
// Push a root node. // Push a root node.
this.huffman_trees[args.which][0][0] = 0 this.huffman_trees[args.which][0][0] = 0
this.huffman_trees[args.which][0][1] = 0 this.huffman_trees[args.which][0][1] = 0
num_nodes = 1 num_branch_nodes = 1
stack_height = 1 stack_height = 1
stack_values[0] = 0 stack_values[0] = 0
@@ -634,17 +634,17 @@ pri func decoder.build_huffman_tree!(which: base.u32[..= 5]) base.status {
node_index = stack_values[stack_height - 1] node_index = stack_values[stack_height - 1]
if this.huffman_trees[args.which][node_index][0] == 0 { if this.huffman_trees[args.which][node_index][0] == 0 {
this.huffman_trees[args.which][node_index][0] = num_nodes as base.u16 this.huffman_trees[args.which][node_index][0] = num_branch_nodes as base.u16
} else { } else {
this.huffman_trees[args.which][node_index][1] = num_nodes as base.u16 this.huffman_trees[args.which][node_index][1] = num_branch_nodes as base.u16
} }
if num_nodes >= 257 { if num_branch_nodes >= 257 {
return "#bad Huffman code (under-subscribed)" return "#bad Huffman code (under-subscribed)"
} }
stack_values[stack_height] = num_nodes stack_values[stack_height] = num_branch_nodes
this.huffman_trees[args.which][num_nodes][0] = 0 this.huffman_trees[args.which][num_branch_nodes][0] = 0
this.huffman_trees[args.which][num_nodes][1] = 0 this.huffman_trees[args.which][num_branch_nodes][1] = 0
num_nodes += 1 num_branch_nodes += 1
stack_height += 1 stack_height += 1
} endwhile } endwhile