Skip to content

Commit

Permalink
patch 8.0.1590: padding in list type wastes memory
Browse files Browse the repository at this point in the history
Problem:    Padding in list type wastes memory.
Solution:   Reorder struct members to optimize padding. (Dominique Pelle,
            closes #2704)
  • Loading branch information
brammool committed Mar 8, 2018
1 parent d7db27b commit 1a84024
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/structs.h
Expand Up @@ -1260,21 +1260,22 @@ struct listwatch_S


/* /*
* Structure to hold info about a list. * Structure to hold info about a list.
* Order of members is optimized to reduce padding.
*/ */
struct listvar_S struct listvar_S
{ {
listitem_T *lv_first; /* first item, NULL if none */ listitem_T *lv_first; /* first item, NULL if none */
listitem_T *lv_last; /* last item, NULL if none */ listitem_T *lv_last; /* last item, NULL if none */
int lv_refcount; /* reference count */
int lv_len; /* number of items */
listwatch_T *lv_watch; /* first watcher, NULL if none */ 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" */ 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() */ 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_next; /* next list in used lists list */
list_T *lv_used_prev; /* previous 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 */
int lv_idx; /* cached index of an item */
int lv_copyID; /* ID used by deepcopy() */
char lv_lock; /* zero, VAR_LOCKED, VAR_FIXED */
}; };


/* /*
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -766,6 +766,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1590,
/**/ /**/
1589, 1589,
/**/ /**/
Expand Down

0 comments on commit 1a84024

Please sign in to comment.