Skip to content

Commit 1a84024

Browse files
committed
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)
1 parent d7db27b commit 1a84024

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/structs.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,21 +1260,22 @@ struct listwatch_S
12601260

12611261
/*
12621262
* Structure to hold info about a list.
1263+
* Order of members is optimized to reduce padding.
12631264
*/
12641265
struct listvar_S
12651266
{
12661267
listitem_T *lv_first; /* first item, NULL if none */
12671268
listitem_T *lv_last; /* last item, NULL if none */
1268-
int lv_refcount; /* reference count */
1269-
int lv_len; /* number of items */
12701269
listwatch_T *lv_watch; /* first watcher, NULL if none */
1271-
int lv_idx; /* cached index of an item */
12721270
listitem_T *lv_idx_item; /* when not NULL item at index "lv_idx" */
1273-
int lv_copyID; /* ID used by deepcopy() */
12741271
list_T *lv_copylist; /* copied list used by deepcopy() */
1275-
char lv_lock; /* zero, VAR_LOCKED, VAR_FIXED */
12761272
list_T *lv_used_next; /* next list in used lists list */
12771273
list_T *lv_used_prev; /* previous list in used lists list */
1274+
int lv_refcount; /* reference count */
1275+
int lv_len; /* number of items */
1276+
int lv_idx; /* cached index of an item */
1277+
int lv_copyID; /* ID used by deepcopy() */
1278+
char lv_lock; /* zero, VAR_LOCKED, VAR_FIXED */
12781279
};
12791280

12801281
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ static char *(features[]) =
766766

767767
static int included_patches[] =
768768
{ /* Add new patch number below this line */
769+
/**/
770+
1590,
769771
/**/
770772
1589,
771773
/**/

0 commit comments

Comments
 (0)