Collection of minor code improvements.

Program should still behave exactly the same.
This commit is contained in:
eelke 2018-10-21 13:46:58 +02:00
parent 38ae5f50e4
commit d4d8316917
6 changed files with 12 additions and 16 deletions

View file

@ -1,7 +1,6 @@
#include "CsvWriter.h"
CsvWriter::CsvWriter()
{}
CsvWriter::CsvWriter() = default;
CsvWriter::CsvWriter(QTextStream *output)
: m_output(output)

View file

@ -71,7 +71,7 @@ ExplainRoot::SPtr ExplainRoot::createFromJson(Json::Value &json)
auto res = std::make_shared<ExplainRoot>();
// Explain always seems to be an array with one element
if (json.isArray()) {
if (json.size() > 0) {
if (!json.empty()) {
Json::Value &explain = json[0];
Json::Value &plan = explain["Plan"];
@ -89,7 +89,7 @@ ExplainTreeModelItem::ExplainTreeModelItem() = default;
ExplainTreeModelItem::~ExplainTreeModelItem() = default;
void ExplainTreeModelItem::appendChild(ItemPtr child)
void ExplainTreeModelItem::appendChild(const ItemPtr &child)
{
child->setParent(shared_from_this());
m_childItems.push_back(child);
@ -132,7 +132,7 @@ int ExplainTreeModelItem::row() const
return idx;
}
void ExplainTreeModelItem::setParent(ItemPtr parent)
void ExplainTreeModelItem::setParent(const ItemPtr &parent)
{
m_parentItem = parent;
}
@ -306,7 +306,7 @@ ExplainTreeModelItemPtr ExplainTreeModelItem::parent()
float ExplainTreeModelItem::exclusiveTime() const
{
float tt = inclusiveTime();
for (auto c : m_childItems) {
for (auto&& c : m_childItems) {
tt -= c->inclusiveTime();
}
return tt;

View file

@ -56,14 +56,14 @@ public:
ExplainTreeModelItem(const ExplainTreeModelItem &rhs) = delete;
ExplainTreeModelItem &operator=(const ExplainTreeModelItem &rhs) = delete;
void appendChild(ItemPtr child);
void appendChild(const ItemPtr &child);
ExplainTreeModelItemPtr child(int row);
int childCount() const;
// int columnCount() const;
// QVariant data(int column) const;
int row() const;
void setParent(ItemPtr parent);
void setParent(const ItemPtr &parent);
ItemPtr parent();
@ -112,7 +112,7 @@ public:
std::weak_ptr<ExplainTreeModelItem> m_parentItem;
QString nodeType;
bool parallelAware; // 9.6
bool parallelAware = false; // 9.6
QString strategy;
QString joinType;
float startupCost = 0.f;

View file

@ -2,7 +2,4 @@
using namespace SqlAst;
Node::Node()
{
}
Node::Node() = default;

View file

@ -42,8 +42,7 @@ QSize IconColumnDelegate::sizeHint(const QStyleOptionViewItem &,
void IconColumnDelegate::clearCache()
{
for (auto &e : m_Icons)
delete e.
second;
delete e.second;
m_Icons.clear();
}

View file

@ -3,6 +3,7 @@
#include "Pgsql_oids.h"
#include "ResultTableModelUtil.h"
#include "CustomDataRole.h"
PgLabItemDelegate::PgLabItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
@ -81,7 +82,7 @@ void PgLabItemDelegate::initStyleOption(QStyleOptionViewItem *option,
// }
Oid oid = InvalidOid;
value = index.data(Qt::UserRole); // get OID
value = index.data(CustomDataTypeRole); // get OID
if (value.isValid())
oid = value.toUInt(); //getType(index.column());