flood_fill_seed: Switch from goto to while

This commit is contained in:
YAMAMOTO Takashi 2021-05-11 14:48:55 +09:00
parent a436fde8a0
commit 87ca2b6c2d

View file

@ -16,6 +16,7 @@
#include <limits.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>
#include "quirc_internal.h"
@ -213,9 +214,7 @@ static void flood_fill_seed(struct quirc *q,
QUIRC_ASSERT(from != to);
QUIRC_ASSERT(q->pixels[y0 * q->w + x0] == from);
struct quirc_flood_fill_vars *vars;
struct quirc_flood_fill_vars *next_vars;
quirc_pixel_t *row;
/* Set up the first context */
next_vars = stack;
@ -228,12 +227,12 @@ static void flood_fill_seed(struct quirc *q,
&next_vars->left_up, &next_vars->right);
next_vars->left_down = next_vars->left_up;
call:
return_from_call:
vars = next_vars;
while (true) {
struct quirc_flood_fill_vars * const vars = next_vars;
quirc_pixel_t *row;
if (vars == last_vars) {
return;
break;
}
/* Seed new flood-fills */
@ -245,7 +244,7 @@ return_from_call:
func, user_data,
vars, -1);
if (next_vars != NULL) {
goto call;
continue;
}
}
@ -257,14 +256,17 @@ return_from_call:
func, user_data,
vars, 1);
if (next_vars != NULL) {
goto call;
continue;
}
}
if (vars > stack) {
/* Restore the previous context */
next_vars = vars - 1;
goto return_from_call;
continue;
}
break;
}
}