mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 14:27:30 -04:00
refactor(file_scanner): replace for_each with ranges
This commit is contained in:
parent
bdbb40f928
commit
82b2600133
@ -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);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user