summaryrefslogtreecommitdiff
path: root/parse-options-cb.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-02-09 15:55:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-10 17:42:43 (GMT)
commita277d0a67f0324deb58abbeb0c5a2b3abbcde340 (patch)
tree1d5ddfb6936780d3b99e925c598d523cf82232d3 /parse-options-cb.c
parentd0654dc308b0ba76dd8ed7bbb33c8d8f7aacd783 (diff)
downloadgit-a277d0a67f0324deb58abbeb0c5a2b3abbcde340.zip
git-a277d0a67f0324deb58abbeb0c5a2b3abbcde340.tar.gz
git-a277d0a67f0324deb58abbeb0c5a2b3abbcde340.tar.bz2
parse-options: use COPY_ARRAY in parse_options_concat()
Use COPY_ARRAY to copy whole arrays instead of iterating through the elements. That's shorter, simpler and bit more efficient. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options-cb.c')
-rw-r--r--parse-options-cb.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c
index c2062ae..012e048 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -188,11 +188,8 @@ struct option *parse_options_concat(struct option *a, struct option *b)
b_len++;
ALLOC_ARRAY(ret, st_add3(a_len, b_len, 1));
- for (i = 0; i < a_len; i++)
- ret[i] = a[i];
- for (i = 0; i < b_len; i++)
- ret[a_len + i] = b[i];
- ret[a_len + b_len] = b[b_len]; /* final OPTION_END */
+ COPY_ARRAY(ret, a, a_len);
+ COPY_ARRAY(ret + a_len, b, b_len + 1); /* + 1 for final OPTION_END */
return ret;
}