]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1508: string manipulation can be improved in cmdexpand.c v9.1.1508
authorJohn Marriott <basilisk@internode.on.net>
Thu, 3 Jul 2025 19:28:50 +0000 (21:28 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 3 Jul 2025 19:28:50 +0000 (21:28 +0200)
commita494ce1c64a2637719a5c1339abf19ec7c48089c
treed06352dbe7a5c71f01d156624c5f80135bf427a2
parentc233c2e6a54778e034d62473e48421f25b2f5069
patch 9.1.1508: string manipulation can be improved in cmdexpand.c

Problem:  String manipulation can be improved in cmdexpand.c
Solution: Refactor cmdexpand.c to remove calls to
          STRLEN()/STRMOVE()/STRCAT() (John Marriott)

This commit does the following:

In function nextwild():
  - slightly refactor the for loop to remove an array access
  - call STRLEN() and store it's result for reuse
  - move some variables closer to where they are used, renaming some on
    the way

In function ExpandOne():
  - move some calculations outside of the for loops
  - factor out calls to STRCAT() (which has an inherent STRLEN() call) in
    the for loop
  - move some variables closer to where they are used

In function expand_files_and_dirs():
  - factor out calls to STRMOVE() (which has an inherent STRLEN() call)

In function get_filetypecmd_arg():
  - move declarations of the string arrays into the blocks where they are
    used

In function get_breakadd_arg():
  - move declaration of the string array into the block where it is
    used

In function globpath():
  - factor out calls to STRLEN() and STRCAT()
  - move some variables closer to where they are used

And finally some minor cosmetic style changes

closes: #17639

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/version.c