删除注释

This commit is contained in:
anxinglong 2026-06-12 18:53:48 +08:00
parent cad4ee2df7
commit 2e6e78ada3

View File

@ -750,12 +750,10 @@ void MainWindow::changeChannelParticleCount(QList<ParticleData> &data)
bool hasError = false;
QHash<uint, QString> newChannelFiles; // 本次新增的通道文件
// 处理每个通道的计数更新
for (auto channelIt = deltaCounts.constBegin(); channelIt != deltaCounts.constEnd(); ++channelIt) {
uint channel_num = channelIt.key();
const auto& addressDeltas = channelIt.value();
// 关键优化如果是新通道初始化4096个道址为0
if (!channel_address_counts.contains(channel_num)) {
std::array<unsigned long long, 4096> initCounts;
initCounts.fill(0); // 所有道址初始化为0
@ -770,7 +768,6 @@ void MainWindow::changeChannelParticleCount(QList<ParticleData> &data)
channelCounts[address] += delta;
}
// 获取或创建通道文件名
QString count_data_filename;
if (particle_count_filename_list.contains(channel_num)) {
count_data_filename = particle_count_filename_list[channel_num];
@ -781,7 +778,6 @@ void MainWindow::changeChannelParticleCount(QList<ParticleData> &data)
newChannelFiles.insert(channel_num, count_data_filename);
}
// 重写整个CSV文件Truncate模式
QFile outFile(count_data_filename);
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
LOG_ERROR(QStringLiteral(u"无法打开通道%1的计数文件: %2错误: %3")
@ -798,10 +794,8 @@ void MainWindow::changeChannelParticleCount(QList<ParticleData> &data)
// 写入表头
out << QStringLiteral(u"道址,计数\n");
// 关键修改写入完整的0-4095道址数据
QString csvBuffer;
csvBuffer.reserve(4096 * 32); // 预分配足够内存约128KB
csvBuffer.reserve(4096 * 32);
for (int address = 0; address < 4096; ++address) {
unsigned long long total = channelCounts[address];
csvBuffer += QString("%1,%2\n").arg(address).arg(total);