From 2ab2aac73d234ae75096e2186b07cc14c57d2586 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 1 Aug 2025 15:04:23 -0700 Subject: string-list: split-then-remove-empty can be done while splitting Thanks to the new STRING_LIST_SPLIT_NONEMPTY flag, a common pattern to split a string into a string list and then remove empty items in the resulting list is no longer needed. Instead, just tell the string_list_split*() to omit empty ones while splitting. Signed-off-by: Junio C Hamano --- t/helper/test-hashmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/helper/test-hashmap.c') diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c index 7782ae585e..e4dc02bd7a 100644 --- a/t/helper/test-hashmap.c +++ b/t/helper/test-hashmap.c @@ -149,8 +149,8 @@ int cmd__hashmap(int argc UNUSED, const char **argv UNUSED) /* break line into command and up to two parameters */ string_list_setlen(&parts, 0); - string_list_split_in_place(&parts, line.buf, DELIM, 2); - string_list_remove_empty_items(&parts, 0); + string_list_split_in_place_f(&parts, line.buf, DELIM, 2, + STRING_LIST_SPLIT_NONEMPTY); /* ignore empty lines */ if (!parts.nr) -- cgit v1.2.3