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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/indexer.c b/src/indexer.c
index 744a03c..91b9b52 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -528,14 +528,11 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats)
{
int error = -1;
- size_t processed;
struct git_pack_header *hdr = &idx->hdr;
git_mwindow_file *mwf = &idx->pack->mwf;
assert(idx && data && stats);
- processed = stats->indexed_objects;
-
if ((error = append_to_pack(idx, data, size)) < 0)
return error;
@@ -578,7 +575,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
stats->local_objects = 0;
stats->total_deltas = 0;
stats->indexed_deltas = 0;
- processed = stats->indexed_objects = 0;
+ stats->indexed_objects = 0;
stats->total_objects = total_objects;
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
/* As the file grows any windows we try to use will be out of date */
git_mwindow_free_all(mwf);
- while (processed < idx->nr_objects) {
+ while (stats->indexed_objects < idx->nr_objects) {
git_packfile_stream *stream = &idx->stream;
git_off_t entry_start = idx->off;
size_t entry_size;
@@ -665,7 +662,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
goto on_error;
if (!idx->have_delta) {
- stats->indexed_objects = (unsigned int)++processed;
+ stats->indexed_objects++;
}
stats->received_objects++;