ast: simplify AppendStmt Signed-off-by: Ran Benita <ran234@gmail.com>
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 4ce4752..ad249ad 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -68,21 +68,17 @@ malloc_or_die(size_t size)
}
ParseCommon *
-AppendStmt(ParseCommon * to, ParseCommon * append)
+AppendStmt(ParseCommon *to, ParseCommon *append)
{
- ParseCommon *start = to;
+ ParseCommon *iter;
- if (append == NULL)
- return to;
- while ((to != NULL) && (to->next != NULL))
- {
- to = to->next;
- }
- if (to) {
- to->next = append;
- return start;
- }
- return append;
+ if (!to)
+ return append;
+
+ for (iter = to; iter->next; iter = iter->next);
+
+ iter->next = append;
+ return to;
}
ExprDef *