forked from qt-creator/qt-creator
Sqlite: Use string view as result value
String view is returning simply the string pointer and the size from the database. In that way we remove useless copies to an intermediate data type. Change-Id: I3354061938c52df585e91054a97c900ae4cd39b3 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -436,10 +436,10 @@ static StringType convertToTextForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||
case SQLITE_FLOAT:
|
||||
case SQLITE3_TEXT: return textForColumn<StringType>(sqlStatment, column);
|
||||
case SQLITE_BLOB:
|
||||
case SQLITE_NULL: return {};
|
||||
case SQLITE_NULL: break;
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
return StringType{"", 0};
|
||||
}
|
||||
|
||||
int BaseStatement::fetchIntValue(int column) const
|
||||
@@ -500,17 +500,12 @@ StringType BaseStatement::fetchValue(int column) const
|
||||
return convertToTextForColumn<StringType>(m_compiledStatement.get(), column);
|
||||
}
|
||||
|
||||
Utils::SmallString BaseStatement::fetchSmallStringValue(int column) const
|
||||
Utils::SmallStringView BaseStatement::fetchSmallStringViewValue(int column) const
|
||||
{
|
||||
return fetchValue<Utils::SmallString>(column);
|
||||
}
|
||||
|
||||
Utils::PathString BaseStatement::fetchPathStringValue(int column) const
|
||||
{
|
||||
return fetchValue<Utils::PathString>(column);
|
||||
return fetchValue<Utils::SmallStringView>(column);
|
||||
}
|
||||
|
||||
template SQLITE_EXPORT Utils::SmallStringView BaseStatement::fetchValue<Utils::SmallStringView>(int column) const;
|
||||
template SQLITE_EXPORT Utils::SmallString BaseStatement::fetchValue<Utils::SmallString>(int column) const;
|
||||
template SQLITE_EXPORT Utils::PathString BaseStatement::fetchValue<Utils::PathString>(int column) const;
|
||||
|
||||
} // namespace Sqlite
|
||||
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
long fetchLongValue(int column) const;
|
||||
long long fetchLongLongValue(int column) const;
|
||||
double fetchDoubleValue(int column) const;
|
||||
Utils::SmallString fetchSmallStringValue(int column) const;
|
||||
Utils::PathString fetchPathStringValue(int column) const;
|
||||
Utils::SmallStringView fetchSmallStringViewValue(int column) const;
|
||||
template<typename Type>
|
||||
Type fetchValue(int column) const;
|
||||
int columnCount() const;
|
||||
@@ -142,6 +141,7 @@ template <> SQLITE_EXPORT int BaseStatement::fetchValue<int>(int column) const;
|
||||
template <> SQLITE_EXPORT long BaseStatement::fetchValue<long>(int column) const;
|
||||
template <> SQLITE_EXPORT long long BaseStatement::fetchValue<long long>(int column) const;
|
||||
template <> SQLITE_EXPORT double BaseStatement::fetchValue<double>(int column) const;
|
||||
extern template SQLITE_EXPORT Utils::SmallStringView BaseStatement::fetchValue<Utils::SmallStringView>(int column) const;
|
||||
extern template SQLITE_EXPORT Utils::SmallString BaseStatement::fetchValue<Utils::SmallString>(int column) const;
|
||||
extern template SQLITE_EXPORT Utils::PathString BaseStatement::fetchValue<Utils::PathString>(int column) const;
|
||||
|
||||
@@ -323,14 +323,9 @@ private:
|
||||
return statement.fetchDoubleValue(column);
|
||||
}
|
||||
|
||||
operator Utils::SmallString()
|
||||
operator Utils::SmallStringView()
|
||||
{
|
||||
return statement.fetchSmallStringValue(column);
|
||||
}
|
||||
|
||||
operator Utils::PathString()
|
||||
{
|
||||
return statement.fetchPathStringValue(column);
|
||||
return statement.fetchSmallStringViewValue(column);
|
||||
}
|
||||
|
||||
StatementImplementation &statement;
|
||||
|
||||
Reference in New Issue
Block a user