From b45850388ea5505f4fd50cd659abe2f02aeca0b5 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 16 Aug 2019 19:52:42 +0200 Subject: cleanup: internalize deduplication list in data_writer This change removes the need for passing a list of files around for deduplication. Also the deduplication code no longer needs to worry about order, since the file being deduplicated is only added after deduplication is done. Signed-off-by: David Oberhollenzer --- lib/fstree/deduplicate.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lib/fstree') diff --git a/lib/fstree/deduplicate.c b/lib/fstree/deduplicate.c index 7390a2c..00815a6 100644 --- a/lib/fstree/deduplicate.c +++ b/lib/fstree/deduplicate.c @@ -16,10 +16,8 @@ file_info_t *fragment_by_chksum(file_info_t *fi, uint32_t chksum, file_info_t *it; for (it = list; it != NULL; it = it->next) { - if (it == fi) { - it = NULL; - break; - } + if (it == fi) + continue; if (!(it->flags & FILE_FLAG_HAS_FRAGMENT)) continue; @@ -82,10 +80,8 @@ uint64_t find_equal_blocks(file_info_t *file, file_info_t *list, } for (it = list; it != NULL; it = it->next) { - if (it == file) { - it = NULL; - break; - } + if (it == file) + continue; if (it->flags & FILE_FLAG_BLOCKS_ARE_DUPLICATE) continue; -- cgit v1.2.3