changeset 13431:19f9b74a424e v8.0.1590

patch 8.0.1590: padding in list type wastes memory commit https://github.com/vim/vim/commit/1a840240376f2858d489736f9eed6d2975225fdf Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 8 21:46:43 2018 +0100 patch 8.0.1590: padding in list type wastes memory Problem: Padding in list type wastes memory. Solution: Reorder struct members to optimize padding. (Dominique Pelle, closes #2704)
author Christian Brabandt <cb@256bit.org>
date Thu, 08 Mar 2018 22:00:05 +0100
parents 6083ee98c089
children b57ba17e3e59
files src/structs.h src/version.c
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/structs.h
+++ b/src/structs.h
@@ -1260,21 +1260,22 @@ struct listwatch_S
 
 /*
  * Structure to hold info about a list.
+ * Order of members is optimized to reduce padding.
  */
 struct listvar_S
 {
     listitem_T	*lv_first;	/* first item, NULL if none */
     listitem_T	*lv_last;	/* last item, NULL if none */
+    listwatch_T	*lv_watch;	/* first watcher, NULL if none */
+    listitem_T	*lv_idx_item;	/* when not NULL item at index "lv_idx" */
+    list_T	*lv_copylist;	/* copied list used by deepcopy() */
+    list_T	*lv_used_next;	/* next list in used lists list */
+    list_T	*lv_used_prev;	/* previous list in used lists list */
     int		lv_refcount;	/* reference count */
     int		lv_len;		/* number of items */
-    listwatch_T	*lv_watch;	/* first watcher, NULL if none */
     int		lv_idx;		/* cached index of an item */
-    listitem_T	*lv_idx_item;	/* when not NULL item at index "lv_idx" */
     int		lv_copyID;	/* ID used by deepcopy() */
-    list_T	*lv_copylist;	/* copied list used by deepcopy() */
     char	lv_lock;	/* zero, VAR_LOCKED, VAR_FIXED */
-    list_T	*lv_used_next;	/* next list in used lists list */
-    list_T	*lv_used_prev;	/* previous list in used lists list */
 };
 
 /*
--- a/src/version.c
+++ b/src/version.c
@@ -767,6 +767,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1590,
+/**/
     1589,
 /**/
     1588,