return data.timeStamp;
}
column = column / 2;
+ Q_ASSERT(column < ChartRows::MAX_NUM_COST);
- const auto cost = data.cost.value(column);
+ const auto cost = data.cost[column];
if (role == Qt::ToolTipRole) {
const QString time = QString::number(double(data.timeStamp) / 1000, 'g', 3) + QLatin1Char('s');
const auto label = m_data.labels.value(column);
#include <QAbstractTableModel>
#include <QVector>
+#include <array>
struct ChartRows
{
+ ChartRows()
+ {
+ cost.fill(0);
+ }
+ enum {
+ MAX_NUM_COST = 20
+ };
quint64 timeStamp = 0;
- QHash<int, quint64> cost;
+ std::array<quint64, MAX_NUM_COST> cost;
};
Q_DECLARE_TYPEINFO(ChartRows, Q_MOVABLE_TYPE);
sort(merged.begin(), merged.end(), [=] (const ChartMergeData& left, const ChartMergeData& right) {
return left.*member > right.*member;
});
- const size_t MAX_CHART_FUNCTIONS = 20;
- for (size_t i = 0; i < min(size_t(MAX_CHART_FUNCTIONS), merged.size()); ++i) {
+ for (size_t i = 0; i < min(size_t(ChartRows::MAX_NUM_COST), merged.size()); ++i) {
const auto& alloc = merged[i];
if (!(alloc.*member)) {
break;
auto createRow = [] (uint64_t timeStamp, uint64_t totalCost) {
ChartRows row;
row.timeStamp = timeStamp;
- row.cost.insert(0, totalCost);
+ row.cost[0] = totalCost;
return row;
};
auto consumed = createRow(newStamp, nowConsumed);