diff --git a/src/executor/query/UnwindExecutor.cpp b/src/executor/query/UnwindExecutor.cpp index 952175172..1a4a2adaf 100644 --- a/src/executor/query/UnwindExecutor.cpp +++ b/src/executor/query/UnwindExecutor.cpp @@ -26,7 +26,7 @@ folly::Future UnwindExecutor::execute() { DataSet ds; ds.colNames = unwind->colNames(); for (; iter->valid(); iter->next()) { - Value list = unwindExpr->eval(ctx(iter.get())); + const Value& list = unwindExpr->eval(ctx(iter.get())); std::vector vals = extractList(list); for (auto &v : vals) { Row row; @@ -41,17 +41,14 @@ folly::Future UnwindExecutor::execute() { return finish(ResultBuilder().value(Value(std::move(ds))).finish()); } -std::vector UnwindExecutor::extractList(Value &val) { +std::vector UnwindExecutor::extractList(const Value &val) { std::vector ret; if (val.isList()) { auto &list = val.getList(); - ret.reserve(list.size()); - for (size_t i = 0; i < list.size(); ++i) { - ret.emplace_back(std::move(list[i])); - } + ret = list.values; } else { if (!(val.isNull() || val.empty())) { - ret.emplace_back(std::move(val)); + ret.push_back(val); } } diff --git a/src/executor/query/UnwindExecutor.h b/src/executor/query/UnwindExecutor.h index 06eeebbf9..3e8f81367 100644 --- a/src/executor/query/UnwindExecutor.h +++ b/src/executor/query/UnwindExecutor.h @@ -20,7 +20,7 @@ class UnwindExecutor final : public Executor { folly::Future execute() override; private: - std::vector extractList(Value &val); + std::vector extractList(const Value &val); }; } // namespace graph