ast: simplify AppendStmt
authorRan Benita <ran234@gmail.com>
Thu, 11 Oct 2012 19:50:21 +0000 (21:50 +0200)
committerRan Benita <ran234@gmail.com>
Thu, 11 Oct 2012 19:51:08 +0000 (21:51 +0200)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/ast-build.c

index 4ce4752..ad249ad 100644 (file)
@@ -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 *