mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-08 20:12:56 -04:00
Pre-sorting
This commit is contained in:
parent
14aed67ade
commit
316d447fe1
@ -445,12 +445,36 @@ void inode_manager_<LoggerPolicy>::order_inodes_by_nilsimsa2(
|
||||
|
||||
log_.info() << "nilsimsa: depth=" << depth << ", limit=" << limit;
|
||||
|
||||
std::sort(index.begin(), index.end(), [&](auto a, auto b) {
|
||||
auto const& ia = *inodes[a];
|
||||
auto const& ib = *inodes[b];
|
||||
return (ia.size() < ib.size() ||
|
||||
(ia.size() == ib.size() && ia.any()->path() < ib.any()->path()));
|
||||
});
|
||||
{
|
||||
auto ti = log_.timed_info();
|
||||
size_t num_name = 0;
|
||||
size_t num_path = 0;
|
||||
|
||||
std::sort(index.begin(), index.end(), [&](auto a, auto b) {
|
||||
auto const& ia = *inodes[a];
|
||||
auto const& ib = *inodes[b];
|
||||
auto sa = ia.size();
|
||||
auto sb = ib.size();
|
||||
if (sa < sb) {
|
||||
return true;
|
||||
} else if (sa > sb) {
|
||||
return false;
|
||||
}
|
||||
++num_name;
|
||||
auto fa = ia.any();
|
||||
auto fb = ib.any();
|
||||
if (fa->name() < fb->name()) {
|
||||
return true;
|
||||
} else if (fa->name() > fb->name()) {
|
||||
return false;
|
||||
}
|
||||
++num_path;
|
||||
return fa->path() < fb->path();
|
||||
});
|
||||
|
||||
ti << "pre-sorted index (" << num_name << " name, " << num_path
|
||||
<< " path lookups)";
|
||||
}
|
||||
|
||||
finalize_inode();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user