summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibSQL/AST/Expression.cpp9
-rw-r--r--Userland/Libraries/LibSQL/AST/Insert.cpp5
-rw-r--r--Userland/Libraries/LibSQL/Tuple.cpp4
3 files changed, 10 insertions, 8 deletions
diff --git a/Userland/Libraries/LibSQL/AST/Expression.cpp b/Userland/Libraries/LibSQL/AST/Expression.cpp
index 839b2cf235..9619648308 100644
--- a/Userland/Libraries/LibSQL/AST/Expression.cpp
+++ b/Userland/Libraries/LibSQL/AST/Expression.cpp
@@ -40,12 +40,13 @@ ResultOr<Value> NestedExpression::evaluate(ExecutionContext& context) const
ResultOr<Value> ChainedExpression::evaluate(ExecutionContext& context) const
{
- Value ret(SQLType::Tuple);
Vector<Value> values;
+ TRY(values.try_ensure_capacity(expressions().size()));
+
for (auto& expression : expressions())
- values.append(TRY(expression.evaluate(context)));
- ret = values;
- return ret;
+ values.unchecked_append(TRY(expression.evaluate(context)));
+
+ return Value { move(values) };
}
ResultOr<Value> BinaryOperatorExpression::evaluate(ExecutionContext& context) const
diff --git a/Userland/Libraries/LibSQL/AST/Insert.cpp b/Userland/Libraries/LibSQL/AST/Insert.cpp
index 48ae68b73a..0c9cfb4fa9 100644
--- a/Userland/Libraries/LibSQL/AST/Insert.cpp
+++ b/Userland/Libraries/LibSQL/AST/Insert.cpp
@@ -47,7 +47,8 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
auto row_value = TRY(row_expr.evaluate(context));
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())
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))
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));
diff --git a/Userland/Libraries/LibSQL/Tuple.cpp b/Userland/Libraries/LibSQL/Tuple.cpp
index 58a96fabe8..fbaa7bed7e 100644
--- a/Userland/Libraries/LibSQL/Tuple.cpp
+++ b/Userland/Libraries/LibSQL/Tuple.cpp
@@ -231,8 +231,8 @@ int Tuple::compare(Tuple const& other) const
int Tuple::match(Tuple const& other) const
{
auto other_index = 0u;
- for (auto& part : *other.descriptor()) {
- auto other_value = other[other_index];
+ for (auto const& part : *other.descriptor()) {
+ auto const& other_value = other[other_index];
if (other_value.is_null())
return 0;
auto my_index = index_of(part.name);