From bd2e66fdea8d2f3763e9509ca9faf64ee26b47a7 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Tue, 23 Mar 2021 13:49:27 +0100 Subject: [PATCH] Move sorting & add a comment --- src/dwarfs/scanner.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dwarfs/scanner.cpp b/src/dwarfs/scanner.cpp index c50895bd..ca2762f7 100644 --- a/src/dwarfs/scanner.cpp +++ b/src/dwarfs/scanner.cpp @@ -167,10 +167,6 @@ class file_scanner { auto& files = p.second; if constexpr (Unique) { - std::sort(files.begin(), files.end(), [](file const* a, file const* b) { - return a->path() < b->path(); - }); - // this is true regardless of how the files are ordered if (files.size() > files.front()->refcount()) { continue; @@ -185,6 +181,11 @@ class file_scanner { DWARFS_CHECK(files.size() > 1, "unexpected non-duplicate file"); } + // this isn't strictly necessary, but helps metadata compression + std::sort(files.begin(), files.end(), [](file const* a, file const* b) { + return a->path() < b->path(); + }); + for (auto fp : files) { // need to check because hardlinks share the same number if (!fp->inode_num()) {