aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-25 08:26:49 +0800
committerGitHub <noreply@github.com>2024-04-25 08:26:49 +0800
commitc32fcd1ed527236e52cfd78033685e713ec36d75 (patch)
tree1749830896b6c1cd31dbe8ea762a5d650f287247 /src/nvim/lua/executor.c
parent7f084770c23855083776b0598f2f54bb59a06875 (diff)
downloadrneovim-c32fcd1ed527236e52cfd78033685e713ec36d75.tar.gz
rneovim-c32fcd1ed527236e52cfd78033685e713ec36d75.tar.bz2
rneovim-c32fcd1ed527236e52cfd78033685e713ec36d75.zip
refactor(source): remove unnecessary concatenation with Lua (#28499)
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 9096cac619..a76b8213e5 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1487,7 +1487,7 @@ static void nlua_typval_exec(const char *lcmd, size_t lcmd_len, const char *name
}
}
-int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name)
+void nlua_source_str(const char *code, char *name)
{
const sctx_T save_current_sctx = current_sctx;
current_sctx.sc_sid = SID_STR;
@@ -1495,22 +1495,11 @@ int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name)
current_sctx.sc_lnum = 0;
estack_push(ETYPE_SCRIPT, name, 0);
- garray_T ga;
- char *line = NULL;
-
- ga_init(&ga, (int)sizeof(char *), 10);
- while ((line = fgetline(0, cookie, 0, false)) != NULL) {
- GA_APPEND(char *, &ga, line);
- }
- char *code = ga_concat_strings_sep(&ga, "\n");
size_t len = strlen(code);
nlua_typval_exec(code, len, name, NULL, 0, false, NULL);
estack_pop();
current_sctx = save_current_sctx;
- ga_clear_strings(&ga);
- xfree(code);
- return OK;
}
/// Call a LuaCallable given some typvals