From 5c8dd9f0fb19add00f63eeca180fd8604266cf8b Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 25 Jan 2011 17:01:09 +0000 Subject: [PATCH] Performance improvement on ARM --- src/misc.h | 2 +- src/preferences/options_imp.cpp | 4 ++-- src/preferences/options_imp.h | 2 +- src/preferences/preferences.h | 4 ++-- src/previewlistdelegate.h | 2 +- src/properties/peerlistdelegate.h | 4 ++-- src/properties/pieceavailabilitybar.h | 6 +++--- src/properties/propertieswidget.cpp | 4 ++-- src/qtlibtorrent/qtorrenthandle.cpp | 8 ++++---- src/qtlibtorrent/qtorrenthandle.h | 6 +++--- src/qtlibtorrent/torrentspeedmonitor.cpp | 6 +++--- src/searchengine/engineselectdlg.cpp | 8 ++++---- src/searchengine/engineselectdlg.h | 2 +- src/searchengine/searchengine.cpp | 2 +- src/searchengine/searchengine.h | 4 ++-- src/torrentfilesmodel.h | 4 ++-- src/webui/eventmanager.cpp | 4 ++-- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/misc.h b/src/misc.h index 73423a5ec..3c8942c40 100644 --- a/src/misc.h +++ b/src/misc.h @@ -153,7 +153,7 @@ public: // use Binary prefix standards from IEC 60027-2 // see http://en.wikipedia.org/wiki/Kilobyte // value must be given in bytes - static QString friendlyUnit(double val); + static QString friendlyUnit(qreal val); static bool isPreviewable(QString extension); static QString branchPath(QString file_path, bool uses_slashes=false); static QString fileName(QString file_path); diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index ae85608c6..1d0f6ea34 100644 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -467,7 +467,7 @@ void options_imp::setStyle(QString style) { void options_imp::loadOptions(){ int intValue; - float floatValue; + qreal floatValue; QString strValue; // General preferences const Preferences pref; @@ -754,7 +754,7 @@ int options_imp::getDHTPort() const { } // Return Share ratio -float options_imp::getMaxRatio() const{ +qreal options_imp::getMaxRatio() const{ if(checkMaxRatio->isChecked()){ return spinMaxRatio->value(); } diff --git a/src/preferences/options_imp.h b/src/preferences/options_imp.h index d9f65a705..c77a327f1 100644 --- a/src/preferences/options_imp.h +++ b/src/preferences/options_imp.h @@ -129,7 +129,7 @@ private: int getDHTPort() const; bool isLSDEnabled() const; int getEncryptionSetting() const; - float getMaxRatio() const; + qreal getMaxRatio() const; // Proxy options bool isProxyEnabled() const; bool isProxyAuthEnabled() const; diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index a4c1aa74a..f3f7c0d3f 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -546,11 +546,11 @@ public: setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val); } - float getMaxRatio() const { + qreal getMaxRatio() const { return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble(); } - void setMaxRatio(float ratio) { + void setMaxRatio(qreal ratio) { setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio); } diff --git a/src/previewlistdelegate.h b/src/previewlistdelegate.h index 218db0380..b489a5d55 100644 --- a/src/previewlistdelegate.h +++ b/src/previewlistdelegate.h @@ -59,7 +59,7 @@ class PreviewListDelegate: public QItemDelegate { QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); break; case PreviewSelect::PROGRESS:{ - float progress = index.data().toDouble()*100.; + qreal progress = index.data().toDouble()*100.; QStyleOptionProgressBarV2 newopt; newopt.rect = opt.rect; newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%"); diff --git a/src/properties/peerlistdelegate.h b/src/properties/peerlistdelegate.h index 1bd32dc1b..e817f9383 100644 --- a/src/properties/peerlistdelegate.h +++ b/src/properties/peerlistdelegate.h @@ -57,14 +57,14 @@ public: case DOWN_SPEED: case UP_SPEED:{ QItemDelegate::drawBackground(painter, opt, index); - double speed = index.data().toDouble(); + qreal speed = index.data().toDouble(); if (speed > 0.0) QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)")); break; } case PROGRESS:{ QItemDelegate::drawBackground(painter, opt, index); - double progress = index.data().toDouble(); + qreal progress = index.data().toDouble(); QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%"); break; } diff --git a/src/properties/pieceavailabilitybar.h b/src/properties/pieceavailabilitybar.h index c9be3d9de..64e9bbb69 100644 --- a/src/properties/pieceavailabilitybar.h +++ b/src/properties/pieceavailabilitybar.h @@ -53,7 +53,7 @@ public: } void setAvailability(const std::vector& avail) { - double average = 0; + qreal average = 0; if(avail.empty()) { // Empty bar QPixmap pix = QPixmap(1, 1); @@ -114,10 +114,10 @@ protected: painter.drawPixmap(rect(), pixmap); } - QColor getPieceColor(int avail, double average) { + QColor getPieceColor(int avail, qreal average) { if(!avail) return Qt::white; //qDebug("avail: %d/%d", avail, max_avail); - double fraction = 100.*average/avail; + qreal fraction = 100.*average/avail; if(fraction < 100) fraction *= 0.8; else diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index daae2c7f3..adef43a0a 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -348,7 +348,7 @@ void PropertiesWidget::loadDynamicData() { // Update next announce time reannounce_lbl->setText(h.next_announce()); // Update ratio info - const double ratio = QBtSession::instance()->getRealRatio(h.hash()); + const qreal ratio = QBtSession::instance()->getRealRatio(h.hash()); if(ratio > 100.) shareRatio->setText(QString::fromUtf8("∞")); else @@ -370,7 +370,7 @@ void PropertiesWidget::loadDynamicData() { showPiecesAvailability(false); } // Progress - float progress = h.progress()*100.; + qreal progress = h.progress()*100.; if(progress > 99.94 && progress < 100.) progress = 99.9; progress_lbl->setText(QString::number(progress, 'f', 1)+"%"); diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index d14f27af3..5abd8ffea 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -88,12 +88,12 @@ qlonglong QTorrentHandle::next_announce_s() const { return torrent_handle::status().next_announce.total_seconds(); } -float QTorrentHandle::progress() const { +qreal QTorrentHandle::progress() const { if(!torrent_handle::status().total_wanted) return 0.; if (torrent_handle::status().total_wanted_done == torrent_handle::status().total_wanted) return 1.; - float progress = (float)torrent_handle::status().total_wanted_done/(float)torrent_handle::status().total_wanted; + qreal progress = (float)torrent_handle::status().total_wanted_done/(float)torrent_handle::status().total_wanted; Q_ASSERT(progress >= 0. && progress <= 1.); return progress; } @@ -159,11 +159,11 @@ size_type QTorrentHandle::total_wanted() const { return torrent_handle::status().total_wanted; } -float QTorrentHandle::download_payload_rate() const { +qreal QTorrentHandle::download_payload_rate() const { return torrent_handle::status().download_payload_rate; } -float QTorrentHandle::upload_payload_rate() const { +qreal QTorrentHandle::upload_payload_rate() const { return torrent_handle::status().upload_payload_rate; } diff --git a/src/qtlibtorrent/qtorrenthandle.h b/src/qtlibtorrent/qtorrenthandle.h index 701bad9b9..9b9a8fdf7 100644 --- a/src/qtlibtorrent/qtorrenthandle.h +++ b/src/qtlibtorrent/qtorrenthandle.h @@ -56,7 +56,7 @@ public: // QString hash() const; QString name() const; - float progress() const; + qreal progress() const; libtorrent::bitfield pieces() const; QString current_tracker() const; bool is_paused() const; @@ -66,8 +66,8 @@ public: int num_pieces() const; libtorrent::size_type total_wanted_done() const; libtorrent::size_type total_wanted() const; - float download_payload_rate() const; - float upload_payload_rate() const; + qreal download_payload_rate() const; + qreal upload_payload_rate() const; int num_connections() const; int connections_limit() const; int num_peers() const; diff --git a/src/qtlibtorrent/torrentspeedmonitor.cpp b/src/qtlibtorrent/torrentspeedmonitor.cpp index 7546281c5..b7946f931 100644 --- a/src/qtlibtorrent/torrentspeedmonitor.cpp +++ b/src/qtlibtorrent/torrentspeedmonitor.cpp @@ -43,7 +43,7 @@ class SpeedSample { public: SpeedSample(){} void addSample(int s); - float average() const; + qreal average() const; void clear(); private: @@ -83,7 +83,7 @@ void SpeedSample::addSample(int s) m_speedSamples.removeFirst(); } -float SpeedSample::average() const +qreal SpeedSample::average() const { if(m_speedSamples.empty()) return 0; qlonglong sum = 0; @@ -114,7 +114,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const QMutexLocker locker(&m_mutex); QTorrentHandle h = m_session->getTorrentHandle(hash); if(h.is_paused() || !m_samples.contains(hash)) return -1; - const float speed_average = m_samples.value(hash).average(); + const qreal speed_average = m_samples.value(hash).average(); if(speed_average == 0) return -1; return (h.total_wanted() - h.total_done()) / speed_average; } diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 3f5021f3f..18f4f1e02 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -224,15 +224,15 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){ return 0; } -bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) const { - float old_version = SearchEngine::getPluginVersion(misc::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py"); +bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const { + qreal old_version = SearchEngine::getPluginVersion(misc::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py"); qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version); return (new_version > old_version); } void engineSelectDlg::installPlugin(QString path, QString plugin_name) { qDebug("Asked to install plugin at %s", qPrintable(path)); - float new_version = SearchEngine::getPluginVersion(path); + qreal new_version = SearchEngine::getPluginVersion(path); qDebug("Version to be installed: %.2f", new_version); if(!isUpdateNeeded(plugin_name, new_version)) { qDebug("Apparently update is not needed, we have a more recent version"); @@ -372,7 +372,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) { if(!plugin_name.endsWith(":")) continue; plugin_name.chop(1); // remove trailing ':' bool ok; - float version = list.last().toFloat(&ok); + qreal version = list.last().toFloat(&ok); qDebug("read line %s: %.2f", qPrintable(plugin_name), version); if(!ok) continue; file_correct = true; diff --git a/src/searchengine/engineselectdlg.h b/src/searchengine/engineselectdlg.h index 4141a5091..1e61b54b7 100644 --- a/src/searchengine/engineselectdlg.h +++ b/src/searchengine/engineselectdlg.h @@ -52,7 +52,7 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{ protected: bool parseVersionsFile(QString versions_file); - bool isUpdateNeeded(QString plugin_name, float new_version) const; + bool isUpdateNeeded(QString plugin_name, qreal new_version) const; signals: void enginesChanged(); diff --git a/src/searchengine/searchengine.cpp b/src/searchengine/searchengine.cpp index 69d816fd6..010e3a585 100644 --- a/src/searchengine/searchengine.cpp +++ b/src/searchengine/searchengine.cpp @@ -188,7 +188,7 @@ SearchEngine::~SearchEngine(){ searchProcess->waitForFinished(); foreach(QProcess *downloader, downloaders) { // Make sure we disconnect the SIGNAL/SLOT first - // To avoid double free + // To avoid qreal free downloader->disconnect(); downloader->kill(); downloader->waitForFinished(); diff --git a/src/searchengine/searchengine.h b/src/searchengine/searchengine.h index a86b52ad1..4c9e628f6 100644 --- a/src/searchengine/searchengine.h +++ b/src/searchengine/searchengine.h @@ -60,7 +60,7 @@ public: ~SearchEngine(); QString selectedCategory() const; - static float getPluginVersion(QString filePath) { + static qreal getPluginVersion(QString filePath) { QFile plugin(filePath); if(!plugin.exists()){ qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath)); @@ -69,7 +69,7 @@ public: if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){ return 0.0; } - float version = 0.0; + qreal version = 0.0; while (!plugin.atEnd()){ QByteArray line = plugin.readLine(); if(line.startsWith("#VERSION: ")){ diff --git a/src/torrentfilesmodel.h b/src/torrentfilesmodel.h index b85ac17be..5461b063b 100644 --- a/src/torrentfilesmodel.h +++ b/src/torrentfilesmodel.h @@ -173,7 +173,7 @@ public: total_done = done; qulonglong size = getSize(); Q_ASSERT(total_done <= size); - float progress; + qreal progress; if(size > 0) progress = total_done/(float)size; else @@ -188,7 +188,7 @@ public: return total_done; } - float getProgress() const { + qreal getProgress() const { if(getPriority() == 0) return 0.; qulonglong size = getSize(); diff --git a/src/webui/eventmanager.cpp b/src/webui/eventmanager.cpp index e3676cc9f..d3cb5e6ca 100644 --- a/src/webui/eventmanager.cpp +++ b/src/webui/eventmanager.cpp @@ -355,7 +355,7 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const { data["time_elapsed"] = elapsed_txt; data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")"); // Update ratio info - double ratio = QBtSession::instance()->getRealRatio(h.hash()); + qreal ratio = QBtSession::instance()->getRealRatio(h.hash()); if(ratio > 100.) data["share_ratio"] = QString::fromUtf8("∞"); else @@ -451,7 +451,7 @@ void EventManager::modifiedTorrent(const QTorrentHandle& h) leechs += " ("+QString::number(h.num_incomplete())+")"; event["num_leechs"] = QVariant(leechs); event["seed"] = QVariant(h.is_seed()); - double ratio = QBtSession::instance()->getRealRatio(hash); + qreal ratio = QBtSession::instance()->getRealRatio(hash); if(ratio > 100.) event["ratio"] = QString::fromUtf8("∞"); else