Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
eliminate one copy in ExtractList of UnwindExecutor (#1276)
Browse files Browse the repository at this point in the history
Co-authored-by: Yee <[email protected]>
  • Loading branch information
jievince and yixinglu authored Jul 23, 2021
1 parent 545aa90 commit 19e5e36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/executor/query/UnwindExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ folly::Future<Status> 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<Value> vals = extractList(list);
for (auto &v : vals) {
Row row;
Expand All @@ -41,17 +41,14 @@ folly::Future<Status> UnwindExecutor::execute() {
return finish(ResultBuilder().value(Value(std::move(ds))).finish());
}

std::vector<Value> UnwindExecutor::extractList(Value &val) {
std::vector<Value> UnwindExecutor::extractList(const Value &val) {
std::vector<Value> 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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/executor/query/UnwindExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UnwindExecutor final : public Executor {
folly::Future<Status> execute() override;

private:
std::vector<Value> extractList(Value &val);
std::vector<Value> extractList(const Value &val);
};

} // namespace graph
Expand Down

0 comments on commit 19e5e36

Please sign in to comment.