Refactor concat_fname() to remove calls to STRLEN()#19854
Open
basilisk0315 wants to merge 3 commits intovim:masterfrom
Open
Refactor concat_fname() to remove calls to STRLEN()#19854basilisk0315 wants to merge 3 commits intovim:masterfrom
basilisk0315 wants to merge 3 commits intovim:masterfrom
Conversation
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
concat_fnames()to remove calls toSTRLEN().Function
concat_fnames()can make up to 5 calls toSTRLEN()(either directly or indirectly viaSTRCAT()). In many cases the lengths of argumentsfname1and/orfname2are either known or can be calculated simply.This PR refactors this function to accept the lengths of arguments
fname1andfname2as arguments. It also adds new argumentretto return the resulting string as astring_T.In addition:
In
scriptfile.c:->In function
add_pack_dir_to_rtp():->->Use a
string_Tto store local variablesnew_rtpandafterdir.->->Replace calls to
STRCAT()with calls toSTRCPY().->->Change type of variable
keeptosize_tfor consistency with other lengths.In
quickfix.c:->In function
qf_get_fnum(), use astring_Tto store local variablesptrandbufname.->In function
qf_push_dir():->->Use a
string_Tto store local variabledirname.->->Replace call to
vim_strsave()withvim_strnsave().->In function
qf_guess_filepath():->->Use a
string_Tto store local variablefullname.In
memline.c:->In function
make_percent_swname():->->Rename some variables to better reflect their use.
->->Use a
string_Tto store local variablesdandfixed_name.->->Slightly refactor to remove need to create an extra string.
->In function
get_file_in_dir():->->Use a
string_Tto store local variablestailandretval.->->Move some variables closer to where they are used.
In
if_cscope.c:->In function
cs_resolve_file():->->Use a
string_Tto store local variablecsdir.->->Remove one call to
STRLEN().In
filepath.c:->Function
add_pathsep()can make up to 2 calls toSTRLEN()(either directory or indirectly viaSTRCAT()). Slightly refactor to remove one call (replacing call toSTRCAT()with a call toSTRCPY()).In
option.c:->In function
set_init_xdg_rtp(), use astring_Tto store local variablevimrc_xdg.Cheers
John