Skip to content

Commit 31c771a

Browse files
jltoblergitster
authored andcommitted
builtin/repo: update stats for each object
When walking reachable objects in the repository, `count_objects()` processes a set of objects and updates the `struct object_stats`. In preparation for more granular statistics being collected, update the `struct object_stats` for each individual object instead. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7c02d39 commit 31c771a

1 file changed

Lines changed: 24 additions & 29 deletions

File tree

builtin/repo.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,6 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
558558
{
559559
struct count_objects_data *data = cb_data;
560560
struct object_stats *stats = data->stats;
561-
size_t inflated_total = 0;
562-
size_t disk_total = 0;
563561
size_t object_count;
564562

565563
for (size_t i = 0; i < oids->nr; i++) {
@@ -575,33 +573,30 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
575573
OBJECT_INFO_QUICK) < 0)
576574
continue;
577575

578-
inflated_total += inflated;
579-
disk_total += disk;
580-
}
581-
582-
switch (type) {
583-
case OBJ_TAG:
584-
stats->type_counts.tags += oids->nr;
585-
stats->inflated_sizes.tags += inflated_total;
586-
stats->disk_sizes.tags += disk_total;
587-
break;
588-
case OBJ_COMMIT:
589-
stats->type_counts.commits += oids->nr;
590-
stats->inflated_sizes.commits += inflated_total;
591-
stats->disk_sizes.commits += disk_total;
592-
break;
593-
case OBJ_TREE:
594-
stats->type_counts.trees += oids->nr;
595-
stats->inflated_sizes.trees += inflated_total;
596-
stats->disk_sizes.trees += disk_total;
597-
break;
598-
case OBJ_BLOB:
599-
stats->type_counts.blobs += oids->nr;
600-
stats->inflated_sizes.blobs += inflated_total;
601-
stats->disk_sizes.blobs += disk_total;
602-
break;
603-
default:
604-
BUG("invalid object type");
576+
switch (type) {
577+
case OBJ_TAG:
578+
stats->type_counts.tags++;
579+
stats->inflated_sizes.tags += inflated;
580+
stats->disk_sizes.tags += disk;
581+
break;
582+
case OBJ_COMMIT:
583+
stats->type_counts.commits++;
584+
stats->inflated_sizes.commits += inflated;
585+
stats->disk_sizes.commits += disk;
586+
break;
587+
case OBJ_TREE:
588+
stats->type_counts.trees++;
589+
stats->inflated_sizes.trees += inflated;
590+
stats->disk_sizes.trees += disk;
591+
break;
592+
case OBJ_BLOB:
593+
stats->type_counts.blobs++;
594+
stats->inflated_sizes.blobs += inflated;
595+
stats->disk_sizes.blobs += disk;
596+
break;
597+
default:
598+
BUG("invalid object type");
599+
}
605600
}
606601

607602
object_count = get_total_object_values(&stats->type_counts);

0 commit comments

Comments
 (0)