diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-02-24 10:17:20 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2024-02-25 11:20:06 +0100 |
commit | 77e928fd3e92f35182237b663437d7ebde7ebde7 (patch) | |
tree | d516508d050cbd7f1d25682e1764fe214e9282e9 /runtime/lua/vim/_defaults.lua | |
parent | 0fcbda59871ebc5fc91cac7fa430a4a93f6698c2 (diff) | |
download | rneovim-77e928fd3e92f35182237b663437d7ebde7ebde7.tar.gz rneovim-77e928fd3e92f35182237b663437d7ebde7ebde7.tar.bz2 rneovim-77e928fd3e92f35182237b663437d7ebde7ebde7.zip |
refactor(fileio): remove API shell layer encouraging unnecessary allocations
Functions like file_open_new() and file_open_fd_new() which just is a
wrapper around the real functions but with an extra xmalloc/xfree around
is an anti-pattern. If the caller really needs to allocate a
FileDescriptor as a heap object, it can do that directly.
FileDescriptor by itself is pretty much a pointer, or rather two:
the OS fd index and a pointer to a buffer. So most of the time an extra
pointer layer is just wasteful.
In the case of scriptin[curscript] in getchar.c, curscript used
to mean in practice:
N+1 open scripts when curscript>0
zero or one open scripts when curscript==0
Which means scriptin[0] had to be compared to NULL to disambiguate the
curscript=0 case.
Instead, use curscript==-1 to mean that are no script,
then all pointer comparisons dissappear and we can just use an array of
structs without extra pointers.
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
0 files changed, 0 insertions, 0 deletions