Skip to content

Commit

Permalink
PSQL: don't recreate QSqlField in loop in QPSQLResult::record()
Browse files Browse the repository at this point in the history
Move out the QSqlField variable out of the loop to avoid useless
(de)allocations of QSqlField.

Change-Id: I2c9e4c84f75e994d5eb1438839d502f6da531841
Reviewed-by: Robert Szefner <[email protected]>
Reviewed-by: Andy Shaw <[email protected]>
  • Loading branch information
chehrlic committed Oct 3, 2019
1 parent dabc33b commit a978d21
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/plugins/sqldrivers/psql/qsql_psql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
Expand Down

0 comments on commit a978d21

Please sign in to comment.