From 9b92cf8ed1ae6fa5e3c3edd94d8a9153eebb31e6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 27 Mar 2014 15:43:09 +0100 Subject: Remove some dead code Keeping redundant copies of the same data is wasteful and error prone. Change-Id: Ie4273d01728acd0caecf20739ae53376ef91ace8 Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/pixmapcachemodel.cpp | 30 +++++------------------ plugins/qmlprofilerextension/pixmapcachemodel.h | 4 +-- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index 7e04f51b391..e3c65c68f72 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -70,12 +70,10 @@ public: void computeMaxCacheSize(); void resizeUnfinishedLoads(); void flattenLoads(); - void computeRowCounts(); int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize, PixmapCacheEvent &newEvent); QVector pixmaps; - int expandedRowCount; int collapsedRowCount; void addVP(QVariantList &l, QString label, qint64 time) const; @@ -91,7 +89,6 @@ PixmapCacheModel::PixmapCacheModel(QObject *parent) { Q_D(PixmapCacheModel); d->collapsedRowCount = 1; - d->expandedRowCount = 1; d->maxCacheSize = 1; } @@ -102,7 +99,7 @@ int PixmapCacheModel::categoryDepth(int categoryIndex) const if (isEmpty()) return 1; if (d->expanded) - return d->expandedRowCount; + return d->pixmaps.count() + 2; return d->collapsedRowCount; } @@ -110,14 +107,15 @@ int PixmapCacheModel::getEventRow(int index) const { Q_D(const PixmapCacheModel); if (d->expanded) - return d->range(index).rowNumberExpanded; + return getEventId(index) + 1; return d->range(index).rowNumberCollapsed; } int PixmapCacheModel::getEventId(int index) const { Q_D(const PixmapCacheModel); - return d->range(index).eventId; + return d->range(index).pixmapEventType == PixmapCacheCountChanged ? + 0 : d->range(index).urlIndex + 1; } QColor PixmapCacheModel::getColor(int index) const @@ -297,9 +295,6 @@ void PixmapCacheModel::loadData() d->pixmaps << Pixmap(event.location.filename); } - newEvent.eventId = newEvent.urlIndex + 1; - newEvent.rowNumberExpanded = newEvent.urlIndex + 2; - Pixmap &pixmap = d->pixmaps[newEvent.urlIndex]; switch (newEvent.pixmapEventType) { case PixmapSizeKnown: {// pixmap size @@ -486,7 +481,6 @@ void PixmapCacheModel::loadData() d->computeMaxCacheSize(); d->flattenLoads(); - d->computeRowCounts(); d->computeNesting(); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); @@ -498,7 +492,6 @@ void PixmapCacheModel::clear() d->SortedTimelineModel::clear(); d->pixmaps.clear(); d->collapsedRowCount = 1; - d->expandedRowCount = 1; d->maxCacheSize = 1; d->expanded = false; @@ -530,6 +523,8 @@ void PixmapCacheModel::PixmapCacheModelPrivate::resizeUnfinishedLoads() void PixmapCacheModel::PixmapCacheModelPrivate::flattenLoads() { + collapsedRowCount = 0; + // computes "compressed row" QVector eventEndTimes; for (int i = 0; i < count(); i++) { @@ -548,22 +543,11 @@ void PixmapCacheModel::PixmapCacheModelPrivate::flattenLoads() // readjust to account for category empty row and bargraph event.rowNumberCollapsed += 2; } - } -} - -void PixmapCacheModel::PixmapCacheModelPrivate::computeRowCounts() -{ - expandedRowCount = 0; - collapsedRowCount = 0; - foreach (const PixmapCacheModel::PixmapCacheEvent &event, ranges) { - if (event.rowNumberExpanded > expandedRowCount) - expandedRowCount = event.rowNumberExpanded; if (event.rowNumberCollapsed > collapsedRowCount) collapsedRowCount = event.rowNumberCollapsed; } // Starting from 0, count is maxIndex+1 - expandedRowCount++; collapsedRowCount++; } @@ -571,8 +555,6 @@ int PixmapCacheModel::PixmapCacheModelPrivate::updateCacheCount(int lastCacheSiz qint64 startTime, qint64 pixSize, PixmapCacheEvent &newEvent) { newEvent.pixmapEventType = PixmapCacheCountChanged; - newEvent.eventId = 0; - newEvent.rowNumberExpanded = 1; newEvent.rowNumberCollapsed = 1; qint64 prevSize = 0; diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h index cbebf71d0d6..fdf20f51951 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.h +++ b/plugins/qmlprofilerextension/pixmapcachemodel.h @@ -35,13 +35,11 @@ class PixmapCacheModel : public QmlProfiler::SingleCategoryTimelineModel public: struct PixmapCacheEvent { - int eventId; int pixmapEventType; int urlIndex; int sizeIndex; - qint64 cacheSize; - int rowNumberExpanded; int rowNumberCollapsed; + qint64 cacheSize; }; enum PixmapEventType { -- cgit v1.2.3