mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make yul::Parser::parse() return unique_ptr rather than shared_ptr
- unique_ptr is more flexible and generally recommended for factory methods. It gets automatically converted to shared_ptr if necessary. Returning shared_ptr, on the other hand, forces the caller to use shared_ptr because a conversion to unique_ptr is not possible.
This commit is contained in:
@@ -37,7 +37,7 @@ using namespace solidity::util;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::yul;
|
||||
|
||||
shared_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
|
||||
unique_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
|
||||
{
|
||||
m_recursionDepth = 0;
|
||||
|
||||
@@ -47,7 +47,7 @@ shared_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _
|
||||
try
|
||||
{
|
||||
m_scanner = _scanner;
|
||||
auto block = make_shared<Block>(parseBlock());
|
||||
auto block = make_unique<Block>(parseBlock());
|
||||
if (!_reuseScanner)
|
||||
expectToken(Token::EOS);
|
||||
return block;
|
||||
|
||||
Reference in New Issue
Block a user