Skip to content

Commit a277d0a

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit a277d0a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

parse-options-cb.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,8 @@ struct option *parse_options_concat(struct option *a, struct option *b)
188188
b_len++;
189189

190190
ALLOC_ARRAY(ret, st_add3(a_len, b_len, 1));
191-
for (i = 0; i < a_len; i++)
192-
ret[i] = a[i];
193-
for (i = 0; i < b_len; i++)
194-
ret[a_len + i] = b[i];
195-
ret[a_len + b_len] = b[b_len]; /* final OPTION_END */
191+
COPY_ARRAY(ret, a, a_len);
192+
COPY_ARRAY(ret + a_len, b, b_len + 1); /* + 1 for final OPTION_END */
196193

197194
return ret;
198195
}

0 commit comments

Comments
 (0)