Pass string length to list_append_string() where it is known#19491
Closed
basilisk0315 wants to merge 5 commits intovim:masterfrom
Closed
Pass string length to list_append_string() where it is known#19491basilisk0315 wants to merge 5 commits intovim:masterfrom
basilisk0315 wants to merge 5 commits intovim:masterfrom
Conversation
Author
|
I am seeing build failures like so: It seems that the compiler is tripping up on this construct (line 1283 in strings.c): ret->string = vim_strnsave((char_u *)"", 0);Strangely, this construct is used elsewhere (see line 643 in file cmdhist.c, line 4952 in file ex_getln.c and line 1409 in file userfunc.c) which does not trigger the same error. In addition, the build times seem to be excessive long. Weird. |
Member
|
can you make this a |
Author
|
Done. Let's see how it likes it. |
Member
|
seems to be fine now |
Member
|
thanks! |
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Feb 26, 2026
Problem: Inefficient use of list_append_string()
Solution: Pass string length to list_append_string() where it is known
(John Marriott).
closes: vim/vim#19491
vim/vim@455d62e
Co-authored-by: John Marriott <[email protected]>
zeertzjq
added a commit
to neovim/neovim
that referenced
this pull request
Feb 26, 2026
…38083) Problem: Inefficient use of list_append_string() Solution: Pass string length to list_append_string() where it is known (John Marriott). closes: vim/vim#19491 vim/vim@455d62e N/A patches: vim-patch:9.2.0063: memory leak in type_name_list_or_dict() vim-patch:9.2.0065: memory leak in invoke_sync_listeners() vim-patch:9.2.0066: memory leak in build_drop_cmd() vim-patch:9.2.0067: memory leak in dict_extend_func() Co-authored-by: John Marriott <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors some source files to pass string length to function
list_append_string()where it is known or can be calculated simply.In addition:
In
evalfunc.c:refactor function
block_def2str()to accept astring_Tto return the resulting string and to drop local variables.refactor function
f_getregion()to restructure the logic within theforloop and to use astring_Tto store stringakt.In
register.c:refactor function
get_reg_contents()to exit the firstforloop if the call tolist_append_string()fails which means we can remove local variableerror.In
strings.c:refactor function
convert_string()to accept astring_Tand anotherstring_Tto return the resulting string.refactor function
string_from_blob()to accept astring_Tto return the resulting string.refactor function
append_converted_string_to_list()to accept argumentconvertedas astring_T.refactor function
append_validated_line_to_list()to accept argumentlineas astring_T.In
evalbuffer.c:refactor function
get_buffer_lines()to callvim_strnsave()instead ofvim_strsave().Cheers
John