From e619fb1660595f9e6a0afad8d9a91e37a94f95a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Feb 2023 10:32:28 +0800 Subject: vim-patch:8.2.0114: info about sourced scripts is scattered Problem: Info about sourced scripts is scattered. Solution: Use scriptitem_T for info about a script, including s: variables. Drop ga_scripts. https://github.com/vim/vim/commit/7ebcba61b20d25d23109fff73d0346ad44ba1b3b Co-authored-by: Bram Moolenaar --- src/nvim/runtime.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/nvim/runtime.h') diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h index 97063b900c..0812355716 100644 --- a/src/nvim/runtime.h +++ b/src/nvim/runtime.h @@ -55,7 +55,16 @@ typedef enum { ESTACK_SCRIPT, } estack_arg_T; -typedef struct scriptitem_S { +/// Holds the hashtab with variables local to each sourced script. +/// Each item holds a variable (nameless) that points to the dict_T. +typedef struct { + ScopeDictDictItem sv_var; + dict_T sv_dict; +} scriptvar_T; + +typedef struct { + scriptvar_T *sn_vars; ///< stores s: variables for this script + char *sn_name; bool sn_prof_on; ///< true when script is/was profiled bool sn_pr_force; ///< forceit: profile functions in this script -- cgit From 0cbbe27e93e87a5336673e0529b011313c51a123 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Feb 2023 11:00:48 +0800 Subject: vim-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. https://github.com/vim/vim/commit/21b9e9773d64de40994f8762173bdd8befa6acf7 Co-authored-by: Bram Moolenaar --- src/nvim/runtime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/runtime.h') diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h index 0812355716..9a810298f8 100644 --- a/src/nvim/runtime.h +++ b/src/nvim/runtime.h @@ -87,7 +87,7 @@ typedef struct { /// Growarray to store info about already sourced scripts. extern garray_T script_items; -#define SCRIPT_ITEM(id) (((scriptitem_T *)script_items.ga_data)[(id) - 1]) +#define SCRIPT_ITEM(id) (((scriptitem_T **)script_items.ga_data)[(id) - 1]) #define SCRIPT_ID_VALID(id) ((id) > 0 && (id) <= script_items.ga_len) typedef void (*DoInRuntimepathCB)(char *, void *); -- cgit