From a5b00b49ec00ae601379a28df733f6de84ff0e9f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 30 Jun 2022 06:32:20 -0500 Subject: [PATCH] Don't typecast something to what it already is. --- toys/pending/diff.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/toys/pending/diff.c b/toys/pending/diff.c index 5a74960e..c70f1b77 100644 --- a/toys/pending/diff.c +++ b/toys/pending/diff.c @@ -78,8 +78,8 @@ struct diff { }; struct candidate { + struct candidate *next, *prev; int a, b; - struct candidate *prev, *next; }; enum { @@ -115,7 +115,7 @@ static int search(struct candidate **K, int r, int k, int j) return -1; } -static struct candidate * new_candidate (int i, int j, struct candidate *prev) +static struct candidate *new_candidate (int i, int j, struct candidate *prev) { struct candidate *c = xzalloc(sizeof(struct candidate)); @@ -125,7 +125,6 @@ static struct candidate * new_candidate (int i, int j, struct candidate *prev) return c; } - static void free_candidates(struct candidate *c) { struct candidate *t = c; @@ -135,8 +134,8 @@ static void free_candidates(struct candidate *c) free(t); } } -/* - * 1. Search K[r: k] for an element K[s] such that K[s]-> b < j and K[s + 1]->b > j + +/* 1. Search K[r: k] for an element K[s] such that K[s]-> b < j and K[s + 1]->b > j * 2. if found do * 2.a. If K[s + 1]->b > j do K[r] = c; r = s+1 and c = candidate(i, j, K[s]) //we have a candidate * 2.b. if s = k (fence reached move it further) do K[k + 2] = K[k + 1], k++ @@ -144,19 +143,18 @@ static void free_candidates(struct candidate *c) * else p = p + 1 //keep traversing the equiv class. * 4. K[r] = c //Save the sucessfully filled k-candidate. */ -static void do_merge(struct candidate **K, int *k, int i, +static void do_merge(struct candidate **K, int *k, int i, struct v_vector *E, int p) { int r = 0, s, j; struct candidate *pr = 0, *c = K[0]; - while (1) { + for (;;) { j = E[p].serial; s = search(K, r, *k, j); - if (s >= 0 && (((struct candidate *)(K[s]))->b < j && - ((struct candidate *)(K[s + 1]))->b > j)) { + if (s>=0 && K[s]->bb>j) { - if (((struct candidate *)(K[s + 1]))->b > j) { + if (K[s + 1]->b>j) { pr = K[s]; if (r && K[r]) c->next = K[r]; K[r] = c; -- 2.39.2