]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1212: too many strlen() calls in edit.c
authorJohn Marriott <basilisk@internode.on.net>
Sun, 16 Mar 2025 19:49:52 +0000 (20:49 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 16 Mar 2025 19:49:52 +0000 (20:49 +0100)
commit34954972c27244a4a1fb4eeeae2aa4e021efd100
tree30dd1a22102c3ae70d00d8589f2032696d49ada5
parent20d23ce93b84ea199d5ea56d7ec86f5e6846d6cc
patch 9.1.1212: too many strlen() calls in edit.c

Problem:  too many strlen() calls in edit.c
Solution: refactor edit.c and remove strlen() calls
          (John Marriott)

This commit attempts to make edit.c more efficient by:

- in truncate_spaces() pass in the length of the string.
- return a string_T from get_last_insert(), so that the length of the
  string is available to the caller.
- refactor stuff_insert():

  - replace calls to stuffReadbuff() (which calls STRLEN() on it's
    string argument) with stuffReadbuffLen() (which gets the length of
    it's string argument passed in).
  - replace call to vim_strrchr() which searches from the start of the
    string with a loop which searches from end of the string to find the
    last ESC character.

- change get_last_insert_save() to call get_last_insert() to get the
  last_insert string (the logic is in one place).

closes: #16863

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/change.c
src/edit.c
src/getchar.c
src/proto/edit.pro
src/proto/getchar.pro
src/register.c