Commit ee5efe06 authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen

Sqlite: Don't copy values for binding

In Sqlite as you bind value you can bind or simply use a reference to the
bound values. Because we hold the values anyway we do not copy them.

Change-Id: I11c6fa5036ea958c8e48e3a117ad4a002d749c22
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke's avatarMarco Bubke <marco.bubke@qt.io>
parent c8701998
...@@ -188,7 +188,7 @@ void Statement::bind(int index, Utils::SmallStringView text) ...@@ -188,7 +188,7 @@ void Statement::bind(int index, Utils::SmallStringView text)
index, index,
text.data(), text.data(),
int(text.size()), int(text.size()),
SQLITE_TRANSIENT); SQLITE_STATIC);
checkForBindingError(resultCode); checkForBindingError(resultCode);
} }
......
...@@ -84,26 +84,26 @@ protected: ...@@ -84,26 +84,26 @@ protected:
} }
template<typename... ValueType> template<typename... ValueType>
void bindValues(ValueType... values) void bindValues(const ValueType&... values)
{ {
bindValuesByIndex(1, values...); bindValuesByIndex(1, values...);
} }
template<typename... ValueType> template<typename... ValueType>
void write(ValueType... values) void write(const ValueType&... values)
{ {
bindValuesByIndex(1, values...); bindValuesByIndex(1, values...);
execute(); execute();
} }
template<typename... ValueType> template<typename... ValueType>
void bindNameValues(ValueType... values) void bindNameValues(const ValueType&... values)
{ {
bindValuesByName(values...); bindValuesByName(values...);
} }
template<typename... ValueType> template<typename... ValueType>
void writeNamed(ValueType... values) void writeNamed(const ValueType&... values)
{ {
bindValuesByName(values...); bindValuesByName(values...);
execute(); execute();
...@@ -420,26 +420,26 @@ private: ...@@ -420,26 +420,26 @@ private:
} }
template<typename ValueType> template<typename ValueType>
void bindValuesByIndex(int index, ValueType value) void bindValuesByIndex(int index, const ValueType &value)
{ {
bind(index, value); bind(index, value);
} }
template<typename ValueType, typename... ValueTypes> template<typename ValueType, typename... ValueTypes>
void bindValuesByIndex(int index, ValueType value, ValueTypes... values) void bindValuesByIndex(int index, const ValueType &value, const ValueTypes&... values)
{ {
bind(index, value); bind(index, value);
bindValuesByIndex(index + 1, values...); bindValuesByIndex(index + 1, values...);
} }
template<typename ValueType> template<typename ValueType>
void bindValuesByName(Utils::SmallStringView name, ValueType value) void bindValuesByName(Utils::SmallStringView name, const ValueType &value)
{ {
bind(bindingIndexForName(name), value); bind(bindingIndexForName(name), value);
} }
template<typename ValueType, typename... ValueTypes> template<typename ValueType, typename... ValueTypes>
void bindValuesByName(Utils::SmallStringView name, ValueType value, ValueTypes... values) void bindValuesByName(Utils::SmallStringView name, const ValueType &value, const ValueTypes&... values)
{ {
bind(bindingIndexForName(name), value); bind(bindingIndexForName(name), value);
bindValuesByName(values...); bindValuesByName(values...);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment