summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-09-29 21:28:52 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-10-03 13:15:47 +0200
commita978d21dac57697ae9557b99062bc804b005b9d4 (patch)
tree38615e3e18cdee9bb3b209c90b70670e778aa3f0 /src/plugins
parentdabc33bf9543e552d8627eda4977e82d340e9bcf (diff)
PSQL: don't recreate QSqlField in loop in QPSQLResult::record()
Move out the QSqlField variable out of the loop to avoid useless (de)allocations of QSqlField. Change-Id: I2c9e4c84f75e994d5eb1438839d502f6da531841 Reviewed-by: Robert Szefner <robertsz27@interia.pl> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 28be7bdc38..3803f05b9f 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -812,8 +812,8 @@ QSqlRecord QPSQLResult::record() const
return info;
int count = PQnfields(d->result);
+ QSqlField f;
for (int i = 0; i < count; ++i) {
- QSqlField f;
if (d->drv_d_func()->isUtf8)
f.setName(QString::fromUtf8(PQfname(d->result, i)));
else
@@ -833,6 +833,8 @@ QSqlRecord QPSQLResult::record() const
}
}
f.setTableName(tableName);
+ } else {
+ f.setTableName(QString());
}
int ptype = PQftype(d->result, i);
f.setType(qDecodePSQLType(ptype));