mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibSQL: Copy SQL::Value instances less frequently (which may be vectors)
This commit is contained in:
parent
5f549fe5d9
commit
c0b54f18b5
3 changed files with 10 additions and 8 deletions
|
@ -40,12 +40,13 @@ ResultOr<Value> NestedExpression::evaluate(ExecutionContext& context) const
|
||||||
|
|
||||||
ResultOr<Value> ChainedExpression::evaluate(ExecutionContext& context) const
|
ResultOr<Value> ChainedExpression::evaluate(ExecutionContext& context) const
|
||||||
{
|
{
|
||||||
Value ret(SQLType::Tuple);
|
|
||||||
Vector<Value> values;
|
Vector<Value> values;
|
||||||
|
TRY(values.try_ensure_capacity(expressions().size()));
|
||||||
|
|
||||||
for (auto& expression : expressions())
|
for (auto& expression : expressions())
|
||||||
values.append(TRY(expression.evaluate(context)));
|
values.unchecked_append(TRY(expression.evaluate(context)));
|
||||||
ret = values;
|
|
||||||
return ret;
|
return Value { move(values) };
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOr<Value> BinaryOperatorExpression::evaluate(ExecutionContext& context) const
|
ResultOr<Value> BinaryOperatorExpression::evaluate(ExecutionContext& context) const
|
||||||
|
|
|
@ -47,7 +47,8 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
|
||||||
|
|
||||||
auto row_value = TRY(row_expr.evaluate(context));
|
auto row_value = TRY(row_expr.evaluate(context));
|
||||||
VERIFY(row_value.type() == SQLType::Tuple);
|
VERIFY(row_value.type() == SQLType::Tuple);
|
||||||
auto values = row_value.to_vector().value();
|
|
||||||
|
auto values = row_value.to_vector().release_value();
|
||||||
|
|
||||||
if (m_column_names.is_empty() && values.size() != row.size())
|
if (m_column_names.is_empty() && values.size() != row.size())
|
||||||
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, String::empty() };
|
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, String::empty() };
|
||||||
|
@ -62,7 +63,7 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
|
||||||
if (!does_value_data_type_match(element_type, input_value_type))
|
if (!does_value_data_type_match(element_type, input_value_type))
|
||||||
return Result { SQLCommand::Insert, SQLErrorCode::InvalidValueType, table_def->columns()[element_index].name() };
|
return Result { SQLCommand::Insert, SQLErrorCode::InvalidValueType, table_def->columns()[element_index].name() };
|
||||||
|
|
||||||
row[element_index] = values[ix];
|
row[element_index] = move(values[ix]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY(context.database->insert(row));
|
TRY(context.database->insert(row));
|
||||||
|
|
|
@ -231,8 +231,8 @@ int Tuple::compare(Tuple const& other) const
|
||||||
int Tuple::match(Tuple const& other) const
|
int Tuple::match(Tuple const& other) const
|
||||||
{
|
{
|
||||||
auto other_index = 0u;
|
auto other_index = 0u;
|
||||||
for (auto& part : *other.descriptor()) {
|
for (auto const& part : *other.descriptor()) {
|
||||||
auto other_value = other[other_index];
|
auto const& other_value = other[other_index];
|
||||||
if (other_value.is_null())
|
if (other_value.is_null())
|
||||||
return 0;
|
return 0;
|
||||||
auto my_index = index_of(part.name);
|
auto my_index = index_of(part.name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue