Merge branch 'rs/cat-file-default-format-optim'

The default format path of git cat-file --batch has been optimized
to use strbuf_add_oid_hex() and strbuf_add_uint() instead of
strbuf_addf(), yielding a noticeable speedup.

* rs/cat-file-default-format-optim:
  cat-file: speed up default format
This commit is contained in:
Junio C Hamano
2026-07-06 15:50:20 -07:00

View File

@@ -458,9 +458,12 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
static void print_default_format(struct strbuf *scratch, struct expand_data *data,
struct batch_options *opt)
{
strbuf_addf(scratch, "%s %s %"PRIuMAX"%c", oid_to_hex(&data->oid),
type_name(data->type),
(uintmax_t)data->size, opt->output_delim);
strbuf_add_oid_hex(scratch, &data->oid);
strbuf_addch(scratch, ' ');
strbuf_addstr(scratch, type_name(data->type));
strbuf_addch(scratch, ' ');
strbuf_add_uint(scratch, data->size);
strbuf_addch(scratch, opt->output_delim);
}
static void report_object_status(struct batch_options *opt,