From 89523789cadf407464135068a8437897820e4299 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Thu, 11 Oct 2012 21:50:21 +0200 Subject: [PATCH] ast: simplify AppendStmt Signed-off-by: Ran Benita --- src/xkbcomp/ast-build.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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 *