Verified Commit 19650d21 authored by Camil Staps's avatar Camil Staps 🚀

Minor efficiency improvements in tools

parent 3810d63d
......@@ -4491,14 +4491,14 @@ static void count_and_renumber_labels(struct label_node *node, int *start, int *
if (label->label_offset < 0 || label->label_module_n < 0) {
label->label_id=*start;
*start=*start+1;
if (label->label_offset < 0) {
global_label_count++;
global_label_string_count+=strlen(label->label_name);
}
} else {
label->label_id=*end;
*end=*end-1;
}
if (label->label_offset < 0) {
global_label_count++;
global_label_string_count+=strlen(label->label_name);
}
if (node->label_node_right != NULL)
count_and_renumber_labels(node->label_node_right, start, end);
......@@ -4551,7 +4551,7 @@ static void print_global_labels(struct label_node *node, FILE *program_file) {
print_global_labels(node->label_node_left, program_file);
struct label *label = node->label_node_label_p;
if (label->label_module_n == - 1 || label->label_offset < 0) {
if (label->label_module_n == -1 || label->label_offset < 0) {
fwrite(&label->label_offset, sizeof(label->label_offset), 1, program_file);
fprintf(program_file, "%s", label->label_name);
fputc('\0', program_file);
......
......@@ -362,9 +362,8 @@ static void activate_label(struct s_label *label) {
ci=0;
uint8_t *code_block=&code[code_indices[ci].byte_index];
int in_block=1;
while (in_block) {
while (1) {
for (struct incoming_labels *ilabs=code_indices[ci].incoming_labels; ilabs!=NULL; ilabs=ilabs->next) {
struct s_label *lab=&labels[ilabs->label_id];
if (lab->bcgen_label==NULL) {
......@@ -436,7 +435,9 @@ static void activate_label(struct s_label *label) {
}
ci++;
}
in_block=!instruction_ends_block(instr);
if (instruction_ends_block(instr))
break;
}
}
}
......
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