mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
Merge pull request #27599 from bfredl/nofilealloc
refactor(fileio): remove API shell layer encouraging unnecessary allocations
This commit is contained in:
@@ -1828,7 +1828,11 @@ bool nlua_exec_file(const char *path)
|
||||
lua_getglobal(lstate, "loadfile");
|
||||
lua_pushstring(lstate, path);
|
||||
} else {
|
||||
FileDescriptor *stdin_dup = file_open_stdin();
|
||||
FileDescriptor stdin_dup;
|
||||
int error = file_open_stdin(&stdin_dup);
|
||||
if (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StringBuilder sb = KV_INITIAL_VALUE;
|
||||
kv_resize(sb, 64);
|
||||
@@ -1837,7 +1841,7 @@ bool nlua_exec_file(const char *path)
|
||||
if (got_int) { // User canceled.
|
||||
return false;
|
||||
}
|
||||
ptrdiff_t read_size = file_read(stdin_dup, IObuff, 64);
|
||||
ptrdiff_t read_size = file_read(&stdin_dup, IObuff, 64);
|
||||
if (read_size < 0) { // Error.
|
||||
return false;
|
||||
}
|
||||
@@ -1849,7 +1853,7 @@ bool nlua_exec_file(const char *path)
|
||||
}
|
||||
}
|
||||
kv_push(sb, NUL);
|
||||
file_free(stdin_dup, false);
|
||||
file_close(&stdin_dup, false);
|
||||
|
||||
lua_getglobal(lstate, "loadstring");
|
||||
lua_pushstring(lstate, sb.items);
|
||||
|
Reference in New Issue
Block a user