refactor(file_scanner): replace for_each with ranges

This commit is contained in:
Marcus Holland-Moritz 2024-05-22 15:35:20 +02:00
parent bdbb40f928
commit 82b2600133

View File

@ -32,6 +32,8 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <range/v3/view/drop.hpp>
#include <dwarfs/checksum.h> #include <dwarfs/checksum.h>
#include <dwarfs/entry.h> #include <dwarfs/entry.h>
#include <dwarfs/file_scanner.h> #include <dwarfs/file_scanner.h>
@ -455,11 +457,10 @@ void file_scanner_<LoggerPolicy>::finalize_hardlinks(Lookup&& lookup) {
auto& hlv = kv.second; auto& hlv = kv.second;
if (hlv.size() > 1) { if (hlv.size() > 1) {
auto& fv = lookup(hlv.front()); auto& fv = lookup(hlv.front());
// TODO: for (auto p : hlv | std::views::drop(1)) for (auto p : ranges::views::drop(hlv, 1)) {
std::for_each(hlv.begin() + 1, hlv.end(), [&fv](auto p) {
p->set_inode(fv.front()->get_inode()); p->set_inode(fv.front()->get_inode());
fv.push_back(p); fv.push_back(p);
}); }
} }
} }