Small optimalization for NULL values

No need to call PQgetvalue() before PQgetisnull().

Change-Id: Ie83ee577b082dbe9d9ca2e86212a281abebdde6e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Robert Szefner 2018-01-07 14:18:39 +01:00 committed by Robert Szefner
parent 43f2d43e8f
commit ca4a76350a

View File

@ -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);
}