Optimize adding new files to FileStats.
GitOrigin-RevId: bceb6a4540f45339fed92c1a83b19d1981634836
This commit is contained in:
parent
0b30530260
commit
bd0621eeff
@ -99,23 +99,23 @@ void FileGcWorker::run_gc(const FileGcParameters ¶meters, std::vector<FullFi
|
|||||||
}
|
}
|
||||||
if (immune_types[narrow_cast<size_t>(info.file_type)]) {
|
if (immune_types[narrow_cast<size_t>(info.file_type)]) {
|
||||||
type_immunity_ignored_cnt++;
|
type_immunity_ignored_cnt++;
|
||||||
new_stats.add(FullFileInfo(info));
|
new_stats.add_copy(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (td::contains(parameters.exclude_owner_dialog_ids, info.owner_dialog_id)) {
|
if (td::contains(parameters.exclude_owner_dialog_ids, info.owner_dialog_id)) {
|
||||||
exclude_owner_dialog_id_ignored_cnt++;
|
exclude_owner_dialog_id_ignored_cnt++;
|
||||||
new_stats.add(FullFileInfo(info));
|
new_stats.add_copy(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!parameters.owner_dialog_ids.empty() && !td::contains(parameters.owner_dialog_ids, info.owner_dialog_id)) {
|
if (!parameters.owner_dialog_ids.empty() && !td::contains(parameters.owner_dialog_ids, info.owner_dialog_id)) {
|
||||||
owner_dialog_id_ignored_cnt++;
|
owner_dialog_id_ignored_cnt++;
|
||||||
new_stats.add(FullFileInfo(info));
|
new_stats.add_copy(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (info.mtime_nsec * 1e-9 > now - parameters.immunity_delay) {
|
if (info.mtime_nsec * 1e-9 > now - parameters.immunity_delay) {
|
||||||
// new files are immune to gc
|
// new files are immune to gc
|
||||||
time_immunity_ignored_cnt++;
|
time_immunity_ignored_cnt++;
|
||||||
new_stats.add(FullFileInfo(info));
|
new_stats.add_copy(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ void FileGcWorker::run_gc(const FileGcParameters ¶meters, std::vector<FullFi
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (pos < files.size()) {
|
while (pos < files.size()) {
|
||||||
new_stats.add(std::move(files[pos]));
|
new_stats.add_copy(files[pos]);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,14 +31,25 @@ void FileStats::add(StatByType &by_type, FileType file_type, int64 size) {
|
|||||||
by_type[pos].cnt++;
|
by_type[pos].cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStats::add(FullFileInfo &&info) {
|
void FileStats::add_impl(const FullFileInfo &info) {
|
||||||
if (split_by_owner_dialog_id) {
|
if (split_by_owner_dialog_id) {
|
||||||
add(stat_by_owner_dialog_id[info.owner_dialog_id], info.file_type, info.size);
|
add(stat_by_owner_dialog_id[info.owner_dialog_id], info.file_type, info.size);
|
||||||
} else {
|
} else {
|
||||||
add(stat_by_type, info.file_type, info.size);
|
add(stat_by_type, info.file_type, info.size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileStats::add_copy(const FullFileInfo &info) {
|
||||||
|
add_impl(info);
|
||||||
if (need_all_files) {
|
if (need_all_files) {
|
||||||
all_files.emplace_back(std::move(info));
|
all_files.push_back(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileStats::add(FullFileInfo &&info) {
|
||||||
|
add_impl(info);
|
||||||
|
if (need_all_files) {
|
||||||
|
all_files.push_back(std::move(info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ struct FileStats {
|
|||||||
|
|
||||||
std::vector<FullFileInfo> all_files;
|
std::vector<FullFileInfo> all_files;
|
||||||
|
|
||||||
|
void add_copy(const FullFileInfo &info);
|
||||||
void add(FullFileInfo &&info);
|
void add(FullFileInfo &&info);
|
||||||
void apply_dialog_limit(int32 limit);
|
void apply_dialog_limit(int32 limit);
|
||||||
|
|
||||||
@ -87,6 +88,7 @@ struct FileStats {
|
|||||||
FileTypeStat get_total_nontemp_stat() const;
|
FileTypeStat get_total_nontemp_stat() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void add_impl(const FullFileInfo &info);
|
||||||
void add(StatByType &by_type, FileType file_type, int64 size);
|
void add(StatByType &by_type, FileType file_type, int64 size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user