Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,23 @@ void MainWindow::slotCompress(const QVariant &val)

bool bUseLibarchive = false;
#ifdef __aarch64__ // 华为arm平台 zip压缩 性能提升. 在多线程场景下使用7z,单线程场景下使用libarchive
double maxFileSizeProportion = static_cast<double>(maxFileSize_) / static_cast<double>(m_stCompressParameter.qSize);
bUseLibarchive = maxFileSizeProportion > 0.6;
// 最大文件超过50MB使用libarchive
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Potential division by zero if qSize is zero.

Add a check to prevent division when qSize is zero to avoid undefined behavior.

if (maxFileSize_ > 50 * 1024 * 1024) {
bUseLibarchive = true;
}
// 总大小超过200MB使用libarchive
else if (m_stCompressParameter.qSize > 200 * 1024 * 1024) {
bUseLibarchive = true;
}
// 总大小超过100MB且最大文件超过10MB使用libarchive(处理均匀分布的大文件)
else if (m_stCompressParameter.qSize > 100 * 1024 * 1024 && maxFileSize_ > 10 * 1024 * 1024) {
bUseLibarchive = true;
}
// 大文件占比超过60%使用libarchive
else {
double maxFileSizeProportion = static_cast<double>(maxFileSize_) / static_cast<double>(m_stCompressParameter.qSize);
bUseLibarchive = maxFileSizeProportion > 0.6;
}
#else
bUseLibarchive = false;
#endif
Expand Down