diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-04 20:29:21 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-03-23 17:03:23 +0000 |
commit | 69948f48997e2995cf212d878839acb4e7c396c3 (patch) | |
tree | 7a1ae4e212c1f42568a673daa5f02115900ab689 /src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | |
parent | 25956a1e7cef0fef39c94638b44c07457b452d00 (diff) |
QSqlResult: use QVector<int> instead QList<int> for indexes value
Minor tweak: QList<int> is taking 64bit per entry, QVector<int>
only 32bit - this should reduce memory usage a little bit.
Change-Id: I3e17269feb4840343f5cecfc71f8fccd70edc80f
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp')
-rw-r--r-- | src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index cb3d905f46..91d2e9b205 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -471,7 +471,7 @@ bool QSQLiteResult::exec() // can end up in a case where for virtual tables it returns 0 even though it // has parameters if (paramCount > 1 && paramCount < values.count()) { - const auto countIndexes = [](int counter, const QList<int>& indexList) { + const auto countIndexes = [](int counter, const QVector<int> &indexList) { return counter + indexList.length(); }; @@ -485,13 +485,14 @@ bool QSQLiteResult::exec() // placeholders. So we need to ensure the QVector has only one instance of // each value as SQLite will do the rest for us. QVector<QVariant> prunedValues; - QList<int> handledIndexes; + QVector<int> handledIndexes; for (int i = 0, currentIndex = 0; i < values.size(); ++i) { if (handledIndexes.contains(i)) continue; const auto placeHolder = QString::fromUtf8(sqlite3_bind_parameter_name(d->stmt, currentIndex + 1)); - handledIndexes << d->indexes[placeHolder]; - prunedValues << values.at(d->indexes[placeHolder].first()); + const auto &indexes = d->indexes.value(placeHolder); + handledIndexes << indexes; + prunedValues << values.at(indexes.first()); ++currentIndex; } values = prunedValues; |