Skip to content

Commit

Permalink
Reduce branches further.
Browse files Browse the repository at this point in the history
  • Loading branch information
nasajoey committed Jan 6, 2024
1 parent ba32dc4 commit 41b7940
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions src/dw_rounding.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,43 +441,42 @@ void print_zeros(int_thread_data* my_data) {
}

/* SAME FLIGHT AS BEFORE. */
else
{ /* Same flight. */
// printf("same flight.\n");
if (strcmp(curr_sector, prev_sector) != 0)
{ /* New sector. */
if (curr_delay > prev_delay)
{ /* New delay. */
new_delay = curr_delay - prev_delay;
prev_delay = curr_delay;
// printf("NEW DELAY: Flight %s, Sector %s, %d minutes.\n", curr_flight, old_sector, new_delay);
// printf("%s %s %d\n", curr_flight, old_sector, new_delay);
// printf("%s %s %d\n", curr_flight, old_sector, new_delay);
fprintf(my_data->zero_file, "%s %s %d\n", curr_flight, old_sector, new_delay);
}
else
{ /* No new delay. */
prev_delay = curr_delay;
}

if (ground_delay)
{
ground_delay = 0;
// printf("NEW_DELAY: Flight %s, Sector %s, %d minutes.\n", curr_flight, prev_sector, curr_delay);
// printf("%s %s %d\n", curr_flight, prev_sector, curr_delay);
fprintf(my_data->zero_file, "%s %s %d\n", curr_flight, prev_sector, curr_delay);
}

strcpy(old_sector, prev_sector);
strcpy(prev_sector, curr_sector);
curr_delay = 1;
else if (strcmp(curr_sector, prev_sector) != 0)
{ /* Same flight and new sector */
//if (strcmp(curr_sector, prev_sector) != 0)
//{ /* New sector. */
if (curr_delay > prev_delay)
{ /* New delay. */
new_delay = curr_delay - prev_delay;
prev_delay = curr_delay;
// printf("NEW DELAY: Flight %s, Sector %s, %d minutes.\n", curr_flight, old_sector, new_delay);
// printf("%s %s %d\n", curr_flight, old_sector, new_delay);
// printf("%s %s %d\n", curr_flight, old_sector, new_delay);
fprintf(my_data->zero_file, "%s %s %d\n", curr_flight, old_sector, new_delay);
}
else
{ /* Same sector as before. */
// printf("Incrementing curr_delay.\n");
curr_delay++;
{ /* No new delay. */
prev_delay = curr_delay;
}

if (ground_delay)
{
ground_delay = 0;
// printf("NEW_DELAY: Flight %s, Sector %s, %d minutes.\n", curr_flight, prev_sector, curr_delay);
// printf("%s %s %d\n", curr_flight, prev_sector, curr_delay);
fprintf(my_data->zero_file, "%s %s %d\n", curr_flight, prev_sector, curr_delay);
}

strcpy(old_sector, prev_sector);
strcpy(prev_sector, curr_sector);
curr_delay = 1;
}
else
{ /* Same sector as before. */
// printf("Incrementing curr_delay.\n");
curr_delay++;
}
//}
}
//if( globals->dw_verbosity >= OUTPUT_NORMAL )
//printf("leaving print_zeros...\n");
Expand Down

0 comments on commit 41b7940

Please sign in to comment.