[PATCH v4 06/11] pretty.c: inline initalize format_context
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Nov 19, 2019, 00:21 UTC
- Message-ID
- <34e1b6a7ac8e1f6f678bee35e9356dead5f45e0b.1574122784.git.liu.denton@gmail.com>
- In-Reply-To
- <cover.1574122784.git.liu.denton@gmail.com>
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> --- pretty.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pretty.c b/pretty.c index 93eb6e8370..4d633f14fa 100644 --- a/pretty.c +++ b/pretty.c @@ -1617,14 +1617,14 @@ void repo_format_commit_message(struct repository *r, const char *format, struct strbuf *sb, const struct pretty_print_context *pretty_ctx) { - struct format_commit_context context; + struct format_commit_context context = { + .commit = commit, + .pretty_ctx = pretty_ctx, + .wrap_start = sb->len + }; const char *output_enc = pretty_ctx->output_encoding; const char *utf8 = "UTF-8"; - memset(&context, 0, sizeof(context)); - context.commit = commit; - context.pretty_ctx = pretty_ctx; - context.wrap_start = sb->len; /* * convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8
-- 2.24.0.420.g9ac4901264