diff src/list.c @ 31201:b1c66bff0a66 v9.0.0934

patch 9.0.0934: various code formatting issues Commit: https://github.com/vim/vim/commit/24fe33a83a5130a5369f06d88000a3a0590a59ec Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 24 00:09:02 2022 +0000 patch 9.0.0934: various code formatting issues Problem: Various code formatting issues. Solution: Improve code formatting.
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Nov 2022 01:15:04 +0100
parents b3de17181c19
children 238ca27dbfd2
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -109,6 +109,8 @@ list_alloc_id(alloc_id_T id UNUSED)
 
 /*
  * Allocate space for a list, plus "count" items.
+ * This uses one allocation for efficiency.
+ * The reference count is not set.
  * Next list_set_item() must be called for each item.
  */
     list_T *
@@ -117,33 +119,34 @@ list_alloc_with_items(int count)
     list_T	*l;
 
     l = (list_T *)alloc_clear(sizeof(list_T) + count * sizeof(listitem_T));
-    if (l != NULL)
+    if (l == NULL)
+	return NULL;
+
+    list_init(l);
+
+    if (count > 0)
     {
-	list_init(l);
-
-	if (count > 0)
+	listitem_T	*li = (listitem_T *)(l + 1);
+	int		i;
+
+	l->lv_len = count;
+	l->lv_with_items = count;
+	l->lv_first = li;
+	l->lv_u.mat.lv_last = li + count - 1;
+	for (i = 0; i < count; ++i)
 	{
-	    listitem_T	*li = (listitem_T *)(l + 1);
-	    int		i;
-
-	    l->lv_len = count;
-	    l->lv_with_items = count;
-	    l->lv_first = li;
-	    l->lv_u.mat.lv_last = li + count - 1;
-	    for (i = 0; i < count; ++i)
-	    {
-		if (i == 0)
-		    li->li_prev = NULL;
-		else
-		    li->li_prev = li - 1;
-		if (i == count - 1)
-		    li->li_next = NULL;
-		else
-		    li->li_next = li + 1;
-		++li;
-	    }
+	    if (i == 0)
+		li->li_prev = NULL;
+	    else
+		li->li_prev = li - 1;
+	    if (i == count - 1)
+		li->li_next = NULL;
+	    else
+		li->li_next = li + 1;
+	    ++li;
 	}
     }
+
     return l;
 }