Git fork

remove unnecessary check before QSORT

Add a semantic patch for removing checks similar to the one that QSORT
already does internally and apply it to the code base.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

René Scharfe and committed by
Junio C Hamano
76dd98c1 9ed0d8d6

+23 -8
+4 -6
builtin/fmt-merge-msg.c
··· 314 314 struct string_list *authors, 315 315 struct string_list *committers) 316 316 { 317 - if (authors->nr) 318 - QSORT(authors->items, authors->nr, 319 - cmp_string_list_util_as_integral); 320 - if (committers->nr) 321 - QSORT(committers->items, committers->nr, 322 - cmp_string_list_util_as_integral); 317 + QSORT(authors->items, authors->nr, 318 + cmp_string_list_util_as_integral); 319 + QSORT(committers->items, committers->nr, 320 + cmp_string_list_util_as_integral); 323 321 324 322 credit_people(out, authors, 'a'); 325 323 credit_people(out, committers, 'c');
+18
contrib/coccinelle/qsort.cocci
··· 17 17 @@ 18 18 - qsort(base, nmemb, sizeof(T), compar); 19 19 + QSORT(base, nmemb, compar); 20 + 21 + @@ 22 + expression base, nmemb, compar; 23 + @@ 24 + - if (nmemb) 25 + QSORT(base, nmemb, compar); 26 + 27 + @@ 28 + expression base, nmemb, compar; 29 + @@ 30 + - if (nmemb > 0) 31 + QSORT(base, nmemb, compar); 32 + 33 + @@ 34 + expression base, nmemb, compar; 35 + @@ 36 + - if (nmemb > 1) 37 + QSORT(base, nmemb, compar);
+1 -2
sh-i18n--envsubst.c
··· 230 230 static inline void 231 231 string_list_sort (string_list_ty *slp) 232 232 { 233 - if (slp->nitems > 0) 234 - QSORT(slp->item, slp->nitems, cmp_string); 233 + QSORT(slp->item, slp->nitems, cmp_string); 235 234 } 236 235 237 236 /* Test whether a sorted string list contains a given string. */