[vim/vim] More use ga_concat_len() where the length is known (PR #19422)

1 view
Skip to first unread message

John Marriott

unread,
Feb 15, 2026, 8:20:50 PM (13 hours ago) Feb 15
to vim/vim, Subscribed

This PR changes some more calls in various source files from ga_concat() to ga_concat_len() where the length is known or can be calculated.

In addition:
In clientserver.c, in function build_drop_cmd() use a string_T for the strings cdp and wig for use in ga_concat_len().
In list.c, in function list_join_inner() use a string_T for the string s for use in ga_concat_len(). Also, change local struct join_T to use string_T.

Cheers
John


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19422

Commit Summary

  • 875099c More use ga_concat_len() where the length is known

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19422@github.com>

h_east

unread,
7:15 AM (2 hours ago) 7:15 AM
to vim/vim, Subscribed
h-east left a comment (vim/vim#19422)

You shouldn't have to specify the literal size directly. Use STRLEN_LITERAL().

ga_concat_len(&ga, (char_u *)"<C-\\><C-N>:cd ", STRLEN_LITERAL("<C-\\><C-N>:cd "));

If writing the literal twice is cumbersome, define a macro. like this:

diff --git a/src/clientserver.c b/src/clientserver.c
index 6eed68f3c..ceca3cb56 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -716,7 +716,7 @@ build_drop_cmd(
 	return NULL;
     cdp.length = STRLEN(cdp.string);
     ga_init2(&ga, 1, 100);
-    ga_concat_len(&ga, (char_u *)"<C-\\><C-N>:cd ", 14);
+    GA_CONCAT_LITERAL(&ga, "<C-\\><C-N>:cd ");
     ga_concat_len(&ga, cdp.string, cdp.length);
     // reset wildignorecase temporarily
     ga_concat_len(&ga, (char_u *)wig[0].string, wig[0].length);
diff --git a/src/vim.h b/src/vim.h
index bd8b4a5d6..2c36e82c6 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -3092,4 +3092,6 @@ long elapsed(DWORD start_tick);
 #define CF_INTERFACE	2	// inside an interface
 #define CF_ABSTRACT_METHOD	4	// inside an abstract class
 
+#define GA_CONCAT_LITERAL(gap,s) ga_concat_len((gap), (char_u *)(s), STRLEN_LITERAL(s))
+
 #endif // VIM__H


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19422/c3908158772@github.com>

Reply all
Reply to author
Forward
0 new messages