@matheusbsbs / matheus-bagliano / commits / 3e8ed3b93e
Fork 0

pretty.c: inline initalize format_context

Instead of memsetting and then initializing the fields in the struct, move the initialization of `format_context` to its assignment. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Nov 19, 2019 at 16:51 UTC 3e8ed3b93e9b46eb6fe61589482751728865de57
1 file changed +5 -5
pretty.c
+5 -5
@@ -1612,14 +1612,14 @@ void repo_format_commit_message(struct repository *r,
1612 const char *format, struct strbuf *sb,
1613 const struct pretty_print_context *pretty_ctx)
1614 {
1615 - struct format_commit_context context;
1615 + struct format_commit_context context = {
1616 + .commit = commit,
1617 + .pretty_ctx = pretty_ctx,
1618 + .wrap_start = sb->len
1619 + };
1620 const char *output_enc = pretty_ctx->output_encoding;
1621 const char *utf8 = "UTF-8";
1622
1619 - memset(&context, 0, sizeof(context));
1620 - context.commit = commit;
1621 - context.pretty_ctx = pretty_ctx;
1622 - context.wrap_start = sb->len;
1623 /*
1624 * convert a commit message to UTF-8 first
1625 * as far as 'format_commit_item' assumes it in UTF-8