Skip to content

Commit 9c0b36d

Browse files
committed
Speed up the loading of row data a bit
This improves the performance for loading row data with my setup by about 10%. Incidentally, the conversion from Qt to STL containers reduced the performance by about the same number.
1 parent e16537d commit 9c0b36d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/RowLoader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ void RowLoader::process (Task & t)
234234

235235
while(!t.cancel && sqlite3_step(stmt) == SQLITE_ROW)
236236
{
237-
Cache::value_type rowdata;
237+
// Construct a new row object with the right number of columns
238+
Cache::value_type rowdata(static_cast<size_t>(num_columns));
238239
for(int i=0;i<num_columns;++i)
239240
{
240-
if(sqlite3_column_type(stmt, i) == SQLITE_NULL)
241+
// No need to do anything for NULL values because we can just use the already default constructed value
242+
if(sqlite3_column_type(stmt, i) != SQLITE_NULL)
241243
{
242-
rowdata.emplace_back();
243-
} else {
244244
int bytes = sqlite3_column_bytes(stmt, i);
245245
if(bytes)
246-
rowdata.emplace_back(static_cast<const char*>(sqlite3_column_blob(stmt, i)), bytes);
246+
rowdata[static_cast<size_t>(i)] = QByteArray(static_cast<const char*>(sqlite3_column_blob(stmt, i)), bytes);
247247
else
248-
rowdata.emplace_back("");
248+
rowdata[static_cast<size_t>(i)] = "";
249249
}
250250
}
251251
QMutexLocker lk(&cache_mutex);

0 commit comments

Comments
 (0)