QSqlTableModel: avoid extra QMap lookup
The consensus on #qt-labs seems to be that there is little or no point in checking with contains() before using value(), even if the map does not contain the key in most cases. Change-Id: I34740a91d5c3af65e20937a5ae3b4bab32406440 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
parent
5d516234be
commit
3a863280dc
@ -439,13 +439,11 @@ QVariant QSqlTableModel::headerData(int section, Qt::Orientation orientation, in
|
||||
{
|
||||
Q_D(const QSqlTableModel);
|
||||
if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
|
||||
if (d->cache.contains(section)) {
|
||||
const QSqlTableModelPrivate::Op op = d->cache.value(section).op();
|
||||
if (op == QSqlTableModelPrivate::Insert)
|
||||
return QLatin1String("*");
|
||||
else if (op == QSqlTableModelPrivate::Delete)
|
||||
return QLatin1String("!");
|
||||
}
|
||||
const QSqlTableModelPrivate::Op op = d->cache.value(section).op();
|
||||
if (op == QSqlTableModelPrivate::Insert)
|
||||
return QLatin1String("*");
|
||||
else if (op == QSqlTableModelPrivate::Delete)
|
||||
return QLatin1String("!");
|
||||
}
|
||||
return QSqlQueryModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user