Am 29.03.22 um 15:56 schrieb Ævar Arnfjörð Bjarmason: > The unpack_one() function will call either a non-trivial > unpack_delta_entry() or a trivial unpack_non_delta_entry(). Let's > inline the latter in the only caller. > > Since 21666f1aae4 (convert object type handling from a string to a > number, 2007-02-26) the unpack_non_delta_entry() function has been > rather trivial, and in a preceding commit the "dry_run" condition it > was handling went away. > > This is not done as an optimization, as the compiler will easily > discover that it can do the same, rather this makes a subsequent > commit easier to reason about. How exactly does inlining the function make the next patch easier to understand or discuss? Plugging in the stream_blob() call to handle the big blobs looks the same with or without the unpack_non_delta_entry() call to me. > As it'll be handling "OBJ_BLOB" in a > special manner let's re-arrange that "case" in preparation for that > change. > > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> > --- > builtin/unpack-objects.c | 18 +++++++----------- > 1 file changed, 7 insertions(+), 11 deletions(-) Reducing the number of lines can be an advantage. *shrug* > > diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c > index e3d30025979..d374599d544 100644 > --- a/builtin/unpack-objects.c > +++ b/builtin/unpack-objects.c > @@ -338,15 +338,6 @@ static void added_object(unsigned nr, enum object_type type, > } > } > > -static void unpack_non_delta_entry(enum object_type type, unsigned long size, > - unsigned nr) > -{ > - void *buf = get_data(size); > - > - if (buf) > - write_object(nr, type, buf, size); > -} > - > static int resolve_against_held(unsigned nr, const struct object_id *base, > void *delta_data, unsigned long delta_size) > { > @@ -479,12 +470,17 @@ static void unpack_one(unsigned nr) > } > > switch (type) { > + case OBJ_BLOB: > case OBJ_COMMIT: > case OBJ_TREE: > - case OBJ_BLOB: > case OBJ_TAG: > - unpack_non_delta_entry(type, size, nr); > + { > + void *buf = get_data(size); > + > + if (buf) > + write_object(nr, type, buf, size); > return; > + } > case OBJ_REF_DELTA: > case OBJ_OFS_DELTA: > unpack_delta_entry(type, size, nr);