Some move semantics improvements.

This commit is contained in:
Grant Wuerker
2019-04-17 14:19:48 +02:00
committed by chriseth
parent 1feefa1ccc
commit 69b4ce36de
10 changed files with 27 additions and 28 deletions
+4 -4
View File
@@ -181,14 +181,14 @@ void CompilerStack::reset(bool _keepSettings)
TypeProvider::reset();
}
void CompilerStack::setSources(StringMap const& _sources)
void CompilerStack::setSources(StringMap _sources)
{
if (m_stackState == SourcesSet)
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Cannot change sources once set."));
if (m_stackState != Empty)
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Must set sources before parsing."));
for (auto const& source: _sources)
m_sources[source.first].scanner = make_shared<Scanner>(CharStream(/*content*/source.second, /*name*/source.first));
for (auto source: _sources)
m_sources[source.first].scanner = make_shared<Scanner>(CharStream(/*content*/std::move(source.second), /*name*/source.first));
m_stackState = SourcesSet;
}
@@ -571,7 +571,7 @@ string CompilerStack::assemblyString(string const& _contractName, StringMap _sou
}
/// TODO: cache the JSON
Json::Value CompilerStack::assemblyJSON(string const& _contractName, StringMap _sourceCodes) const
Json::Value CompilerStack::assemblyJSON(string const& _contractName, StringMap const& _sourceCodes) const
{
if (m_stackState != CompilationSuccessful)
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
+2 -2
View File
@@ -150,7 +150,7 @@ public:
void useMetadataLiteralSources(bool _metadataLiteralSources);
/// Sets the sources. Must be set before parsing.
void setSources(StringMap const& _sources);
void setSources(StringMap _sources);
/// Adds a response to an SMTLib2 query (identified by the hash of the query input).
/// Must be set before parsing.
@@ -238,7 +238,7 @@ public:
/// @returns a JSON representation of the assembly.
/// @arg _sourceCodes is the map of input files to source code strings
/// Prerequisite: Successful compilation.
Json::Value assemblyJSON(std::string const& _contractName, StringMap _sourceCodes = StringMap()) const;
Json::Value assemblyJSON(std::string const& _contractName, StringMap const& _sourceCodes = StringMap()) const;
/// @returns a JSON representing the contract ABI.
/// Prerequisite: Successful call to parse or compile.