Move sorting & add a comment

This commit is contained in:
Marcus Holland-Moritz 2021-03-23 13:49:27 +01:00
parent df5de1f486
commit bd2e66fdea

View File

@ -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()) {