From: Geoffrey Allott Date: Sat, 3 Sep 2022 12:37:53 +0000 (+0100) Subject: clean up node_sort_sons X-Git-Url: https://git.pointlesshacks.com/?a=commitdiff_plain;h=6cbec1b211e982ea3148d3528c8df9c8da0aa02f;p=tANS.git clean up node_sort_sons --- diff --git a/src/stree.c b/src/stree.c index 81122f3..77aa7f1 100644 --- a/src/stree.c +++ b/src/stree.c @@ -71,17 +71,13 @@ static void node_sort_sons(struct node *self) for (brother = (struct node *) 0, node = self->son; node && node->brother; brother = node, node = node->brother) { if (node->to > node->brother->to) { - if (brother) { - tmp = node->brother; - node->brother = node->brother->brother; - tmp->brother = node; + tmp = node->brother; + node->brother = node->brother->brother; + tmp->brother = node; + if (brother) brother->brother = tmp; - } else { - tmp = node->brother; - node->brother = node->brother->brother; - tmp->brother = node; + else self->son = tmp; - } brother = (struct node *) 0; node = self->son; }