patch 8.2.0154: reallocating the list of scripts is inefficient
Problem: Reallocating the list of scripts is inefficient.
Solution: Instead of using a growarray of scriptitem_T, store pointers and
allocate each scriptitem_T separately. Also avoids that the
growarray pointers change when sourcing a new script.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 9f273c5..6690622 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1401,7 +1401,7 @@
{
hashtab_T *ht;
dictitem_T *di;
- scriptitem_T *si = &SCRIPT_ITEM(sid);
+ scriptitem_T *si = SCRIPT_ITEM(sid);
int idx;
// First look the name up in the hashtable.
@@ -1433,7 +1433,7 @@
imported_T *
find_imported(char_u *name, cctx_T *cctx)
{
- scriptitem_T *si = &SCRIPT_ITEM(current_sctx.sc_sid);
+ scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
int idx;
if (cctx != NULL)
@@ -1462,7 +1462,7 @@
static int
compile_load_scriptvar(cctx_T *cctx, char_u *name)
{
- scriptitem_T *si = &SCRIPT_ITEM(current_sctx.sc_sid);
+ scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
int idx = get_script_item_idx(current_sctx.sc_sid, name, FALSE);
imported_T *import;