Reduce shared_ptr copies

This commit is contained in:
Raúl Marín 2022-10-14 15:24:47 +02:00
parent 95bd7eec67
commit 1aa6266c56

View File

@ -46,16 +46,15 @@ bool ParserList::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
if (!elem_parser->parse(pos, element, expected)) if (!elem_parser->parse(pos, element, expected))
return false; return false;
elements.push_back(element); elements.push_back(std::move(element));
return true; return true;
}; };
if (!parseUtil(pos, expected, parse_element, *separator_parser, allow_empty)) if (!parseUtil(pos, expected, parse_element, *separator_parser, allow_empty))
return false; return false;
auto list = std::make_shared<ASTExpressionList>(result_separator); node = std::make_shared<ASTExpressionList>(result_separator);
list->children = std::move(elements); node->children = std::move(elements);
node = list;
return true; return true;
} }
@ -76,7 +75,7 @@ bool ParserUnionList::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
if (!elem_parser.parse(pos, element, expected)) if (!elem_parser.parse(pos, element, expected))
return false; return false;
elements.push_back(element); elements.push_back(std::move(element));
return true; return true;
}; };
@ -120,9 +119,8 @@ bool ParserUnionList::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
if (!parseUtil(pos, parse_element, parse_separator)) if (!parseUtil(pos, parse_element, parse_separator))
return false; return false;
auto list = std::make_shared<ASTExpressionList>(); node = std::make_shared<ASTExpressionList>();
list->children = std::move(elements); node->children = std::move(elements);
node = list;
return true; return true;
} }
@ -242,7 +240,7 @@ bool ParserLeftAssociativeBinaryOperatorList::parseImpl(Pos & pos, ASTPtr & node
if (!elem_parser->parse(pos, elem, expected)) if (!elem_parser->parse(pos, elem, expected))
return false; return false;
node = elem; node = std::move(elem);
first = false; first = false;
} }
else else
@ -1398,7 +1396,7 @@ public:
return false; return false;
auto subquery = std::make_shared<ASTSubquery>(); auto subquery = std::make_shared<ASTSubquery>();
subquery->children.push_back(node); subquery->children.push_back(std::move(node));
elements = {makeASTFunction("exists", subquery)}; elements = {makeASTFunction("exists", subquery)};
finished = true; finished = true;