From cbd8b2c1622e0c1cb4d38b65730e259eb6c100df Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 1 Nov 2024 17:34:19 +0800 Subject: vim-patch:9.1.0824: too many strlen() calls in register.c (#31022) Problem: too many strlen() calls in register.c Solution: refactor code, add string_T struct to keep track of string lengths (John Marriott) closes: vim/vim#15952 https://github.com/vim/vim/commit/79f6ffd388299ef3b1c95cbe658785e6e66df144 Co-authored-by: John Marriott --- src/nvim/api/private/helpers.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/api/private') diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 57932e067e..d06f5c9c65 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -111,6 +111,12 @@ typedef kvec_withinit_t(Object, 16) ArrayBuilder; #define STATIC_CSTR_AS_OBJ(s) STRING_OBJ(STATIC_CSTR_AS_STRING(s)) #define STATIC_CSTR_TO_OBJ(s) STRING_OBJ(STATIC_CSTR_TO_STRING(s)) +#define API_CLEAR_STRING(s) \ + do { \ + XFREE_CLEAR(s.data); \ + s.size = 0; \ + } while (0) + // Helpers used by the generated msgpack-rpc api wrappers #define api_init_boolean #define api_init_integer -- cgit