Skip to content

Commit 92684bb

Browse files
author
Philip Kaufmann
committed
[Qt] minor optimisations in peertablemodel
- remove an unneeded include of net.h in peertablemodel.cpp - add const after size() in PeerTablePriv - remove 2x unneeded else in functions - replace a (int) typecast by (QVariant) to use Qt style - remove unneeded include of peertablemodel.h from rpcconsole.cpp
1 parent c0f66ce commit 92684bb

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/qt/peertablemodel.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "guiconstants.h"
99
#include "guiutil.h"
1010

11-
#include "net.h"
1211
#include "sync.h"
1312

1413
#include <QDebug>
@@ -96,18 +95,17 @@ class PeerTablePriv
9695
mapNodeRows.insert(std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
9796
}
9897

99-
int size()
98+
int size() const
10099
{
101100
return cachedNodeStats.size();
102101
}
103102

104103
CNodeCombinedStats *index(int idx)
105104
{
106-
if(idx >= 0 && idx < cachedNodeStats.size()) {
105+
if (idx >= 0 && idx < cachedNodeStats.size())
107106
return &cachedNodeStats[idx];
108-
} else {
109-
return 0;
110-
}
107+
108+
return 0;
111109
}
112110
};
113111

@@ -171,7 +169,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
171169
}
172170
} else if (role == Qt::TextAlignmentRole) {
173171
if (index.column() == Ping)
174-
return (int)(Qt::AlignRight | Qt::AlignVCenter);
172+
return (QVariant)(Qt::AlignRight | Qt::AlignVCenter);
175173
}
176174

177175
return QVariant();
@@ -204,13 +202,8 @@ QModelIndex PeerTableModel::index(int row, int column, const QModelIndex &parent
204202
CNodeCombinedStats *data = priv->index(row);
205203

206204
if (data)
207-
{
208205
return createIndex(row, column, data);
209-
}
210-
else
211-
{
212-
return QModelIndex();
213-
}
206+
return QModelIndex();
214207
}
215208

216209
const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx)

src/qt/rpcconsole.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "clientmodel.h"
99
#include "guiutil.h"
10-
#include "peertablemodel.h"
1110
#include "platformstyle.h"
1211

1312
#include "chainparams.h"

0 commit comments

Comments
 (0)