From ca4a76350a288589d7caf54548ee08f9d4ab46c1 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Sun, 7 Jan 2018 14:18:39 +0100 Subject: Small optimalization for NULL values No need to call PQgetvalue() before PQgetisnull(). Change-Id: Ie83ee577b082dbe9d9ca2e86212a281abebdde6e Reviewed-by: Edward Welbourne Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/plugins/sqldrivers') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index dfca183ff0..6f105f79ca 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -655,9 +655,9 @@ QVariant QPSQLResult::data(int i) const int currentRow = isForwardOnly() ? 0 : at(); int ptype = PQftype(d->result, i); QVariant::Type type = qDecodePSQLType(ptype); - const char *val = PQgetvalue(d->result, currentRow, i); if (PQgetisnull(d->result, currentRow, i)) return QVariant(type); + const char *val = PQgetvalue(d->result, currentRow, i); switch (type) { case QVariant::Bool: return QVariant((bool)(val[0] == 't')); @@ -742,7 +742,6 @@ bool QPSQLResult::isNull(int field) { Q_D(const QPSQLResult); const int currentRow = isForwardOnly() ? 0 : at(); - PQgetvalue(d->result, currentRow, field); return PQgetisnull(d->result, currentRow, field); } -- cgit v1.2.3