mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 21:50:05 +00:00
vfs: Deduplicate accumulation code in VfsDirectory's GetSize()
We can just use a generic lambda to avoid writing the same thing twice.
This commit is contained in:
parent
1371e2fb6a
commit
5e626c774f
@ -116,14 +116,14 @@ bool VfsDirectory::IsRoot() const {
|
|||||||
|
|
||||||
size_t VfsDirectory::GetSize() const {
|
size_t VfsDirectory::GetSize() const {
|
||||||
const auto& files = GetFiles();
|
const auto& files = GetFiles();
|
||||||
const auto file_total =
|
const auto sum_sizes = [](const auto& range) {
|
||||||
std::accumulate(files.begin(), files.end(), 0ull,
|
return std::accumulate(range.begin(), range.end(), 0ULL,
|
||||||
[](const auto& f1, const auto& f2) { return f1 + f2->GetSize(); });
|
[](const auto& f1, const auto& f2) { return f1 + f2->GetSize(); });
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto file_total = sum_sizes(files);
|
||||||
const auto& sub_dir = GetSubdirectories();
|
const auto& sub_dir = GetSubdirectories();
|
||||||
const auto subdir_total =
|
const auto subdir_total = sum_sizes(sub_dir);
|
||||||
std::accumulate(sub_dir.begin(), sub_dir.end(), 0ull,
|
|
||||||
[](const auto& f1, const auto& f2) { return f1 + f2->GetSize(); });
|
|
||||||
|
|
||||||
return file_total + subdir_total;
|
return file_total + subdir_total;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user