Skip to contentSkip to conversation

merge-recursive: use STRING_LIST_INIT_NODUP

PATCH In review René Scharfe 2 participants 2 messages Aug 5, 2016 – Aug 7, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 merge-recursive: use STRING_LIST_INIT_NODUP

Initialize a string_list right when it's defined. That's shorter, saves a function call and makes it more obvious that we're using the NODUP variant here.

---
 merge-recursive.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
merge-recursive.c +1 -2
index a4a1195..97e6737 100644
@@ -409,7 +409,7 @@ static void record_df_conflict_files(struct merge_options *o,
 	 * and the file need to be present, then the D/F file will be
 	 * reinstated with a new unique name at the time it is processed.
 	 */
-	struct string_list df_sorted_entries;
+	struct string_list df_sorted_entries = STRING_LIST_INIT_NODUP;
 	const char *last_file = NULL;
 	int last_len = 0;
 	int i;
@@ -422,7 +422,6 @@ static void record_df_conflict_files(struct merge_options *o,
 		return;
 
 	/* Ensure D/F conflicts are adjacent in the entries list. */
-	memset(&df_sorted_entries, 0, sizeof(struct string_list));
 	for (i = 0; i < entries->nr; i++) {
 		struct string_list_item *next = &entries->items[i];
 		string_list_append(&df_sorted_entries, next->string)->util =
Signature · 1 line
2.9.2
#1 lore raw

Hi René,

Quoted 3 lines · René Scharfe

Initialize a string_list right when it's defined. That's shorter, saves a function call and makes it more obvious that we're using the NODUP variant here.

Thank you! I guess I never updated the code after the _INIT* macros were introduced.

The change is good, of course.

Thanks,
Dscho