From 8cd940e41aead82921f3d8f5b49d6a9c7773ce40 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 19 Aug 2022 15:07:24 +0200 Subject: Premature optimization based on clazy hint --- src/dal/sqlitedataprovider.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dal/sqlitedataprovider.cpp b/src/dal/sqlitedataprovider.cpp index d83dc274..4b959f98 100644 --- a/src/dal/sqlitedataprovider.cpp +++ b/src/dal/sqlitedataprovider.cpp @@ -370,10 +370,11 @@ const RecordSet &SqLiteDataProvider::processSql() if (!mIsConnected) throw std::runtime_error("not connected to database"); - int totalCols = sqlite3_column_count(mStmt); + const int totalCols = sqlite3_column_count(mStmt); // ensure we set column headers before adding a row Row fieldNames; + fieldNames.reserve(totalCols); for (int col = 0; col < totalCols; ++col) { fieldNames.push_back(sqlite3_column_name(mStmt, col)); @@ -383,6 +384,7 @@ const RecordSet &SqLiteDataProvider::processSql() while (sqlite3_step(mStmt) == SQLITE_ROW) { Row r; + r.reserve(totalCols); for (int col = 0; col < totalCols; ++col) { const unsigned char *txt = sqlite3_column_text(mStmt, col); -- cgit v1.2.3-70-g09d2