From 44921db440f14b9ccc27cf7a5e0384cbe7bf8cf7 Mon Sep 17 00:00:00 2001 From: Dubslow Date: Sun, 18 Jan 2015 13:57:51 -0600 Subject: [PATCH] minor code cleanup --- src/chatlog/content/filetransferwidget.cpp | 9 +++++---- src/chatlog/content/filetransferwidget.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/chatlog/content/filetransferwidget.cpp b/src/chatlog/content/filetransferwidget.cpp index 67444cedd..95e683d7a 100644 --- a/src/chatlog/content/filetransferwidget.cpp +++ b/src/chatlog/content/filetransferwidget.cpp @@ -137,13 +137,14 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file) qreal bytesPerSec = static_cast(static_cast(deltaBytes) / deltaSecs); // calculate mean - meanData[(meanIndex++) % FTW_MEAN_PERIODES] = bytesPerSec; + meanData[meanIndex] = bytesPerSec; + meanIndex = (meanIndex + 1) % TRANSFER_ROLLING_AVG_COUNT; qreal meanBytesPerSec = 0.0; - for(size_t i = 0; i < FTW_MEAN_PERIODES; ++i) + for(size_t i = 0; i < TRANSFER_ROLLING_AVG_COUNT; ++i) meanBytesPerSec += meanData[i]; - meanBytesPerSec /= qMin(meanIndex, static_cast(FTW_MEAN_PERIODES)); + meanBytesPerSec /= qMin(static_cast(meanIndex), static_cast(TRANSFER_ROLLING_AVG_COUNT)); // update UI if(meanBytesPerSec > 0) @@ -209,7 +210,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file) // reset mean meanIndex = 0; - for(size_t i=0; i