Skip to content

Commit 6568f37

Browse files
committed
indexer: remove useless local variable
The `processed` variable local to `git_indexer_append` counts how many objects have already been processed. But actually, whenever it gets assigned to, we are also assigning the same value to the `stats->indexed_objects` struct member. So in fact, it is being quite useless due to always having the same value as the `indexer_objects` member and makes it a bit harder to understand the code. We can just remove the variable to fix that.
1 parent ca4db5f commit 6568f37

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/indexer.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,11 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
528528
int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats)
529529
{
530530
int error = -1;
531-
size_t processed;
532531
struct git_pack_header *hdr = &idx->hdr;
533532
git_mwindow_file *mwf = &idx->pack->mwf;
534533

535534
assert(idx && data && stats);
536535

537-
processed = stats->indexed_objects;
538-
539536
if ((error = append_to_pack(idx, data, size)) < 0)
540537
return error;
541538

@@ -578,7 +575,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
578575
stats->local_objects = 0;
579576
stats->total_deltas = 0;
580577
stats->indexed_deltas = 0;
581-
processed = stats->indexed_objects = 0;
578+
stats->indexed_objects = 0;
582579
stats->total_objects = total_objects;
583580

584581
if ((error = do_progress_callback(idx, stats)) != 0)
@@ -590,7 +587,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
590587
/* As the file grows any windows we try to use will be out of date */
591588
git_mwindow_free_all(mwf);
592589

593-
while (processed < idx->nr_objects) {
590+
while (stats->indexed_objects < idx->nr_objects) {
594591
git_packfile_stream *stream = &idx->stream;
595592
git_off_t entry_start = idx->off;
596593
size_t entry_size;
@@ -665,7 +662,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
665662
goto on_error;
666663

667664
if (!idx->have_delta) {
668-
stats->indexed_objects = (unsigned int)++processed;
665+
stats->indexed_objects++;
669666
}
670667
stats->received_objects++;
671668

0 commit comments

Comments
 (0)