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:
Marco Bubke
2017-10-18 13:37:34 +02:00
committed by Tim Jenssen
parent 507d99f03c
commit 0a3df84533
3 changed files with 25 additions and 32 deletions

View File

@@ -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