Skip to content

Commit 2034e84

Browse files
szedergitster
authored andcommitted
split-index: count the number of deleted entries
'struct split_index' contains the field 'nr_deletions', whose name with the 'nr_' prefix suggests that it contains the number of deleted cache entries. However, barring its initialization to 0, this field is only ever set to 1, indicating that there is at least one deleted entry, but not the number of deleted entries. Luckily, this doesn't cause any issues (other than confusing the reader, that is), because the only place reading this field uses it in the same sense, i.e.: 'if (si->nr_deletions)'. To avoid confusion, we could either rename this field to something like 'has_deletions' to make its name match its role, or make it a counter of deleted cache entries to match its name. Let's make it a counter, to keep it in sync with the related field 'nr_replacements', which does contain the number of replaced cache entries. This will also give developers debugging the split index code easy access to the number of deleted cache entries. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c6e5607 commit 2034e84

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

split-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void mark_entry_for_delete(size_t pos, void *data)
111111
die("position for delete %d exceeds base index size %d",
112112
(int)pos, istate->cache_nr);
113113
istate->cache[pos]->ce_flags |= CE_REMOVE;
114-
istate->split_index->nr_deletions = 1;
114+
istate->split_index->nr_deletions++;
115115
}
116116

117117
static void replace_entry(size_t pos, void *data)

0 commit comments

Comments
 (0)