Misc small refactors: Use ranges::views::keys and fmt::format()

This commit is contained in:
Kamil Śliwak 2023-04-20 19:47:26 +02:00
parent 2f78e9549a
commit ded9ef17e8

View File

@ -82,6 +82,9 @@
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <range/v3/view/concat.hpp> #include <range/v3/view/concat.hpp>
#include <range/v3/view/map.hpp>
#include <fmt/format.h>
#include <utility> #include <utility>
#include <map> #include <map>
@ -710,10 +713,11 @@ bool CompilerStack::compile(State _stopAfter)
1834_error, 1834_error,
Error::Type::CodeGenerationError, Error::Type::CodeGenerationError,
*sourceLocation, *sourceLocation,
"Unimplemented feature error" + fmt::format(
((comment && !comment->empty()) ? ": " + *comment : string{}) + "Unimplemented feature error {} in {}",
" in " + (comment && !comment->empty()) ? ": " + *comment : "",
_unimplementedError.lineInfo() _unimplementedError.lineInfo()
)
); );
return false; return false;
} }
@ -949,10 +953,7 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
vector<string> CompilerStack::sourceNames() const vector<string> CompilerStack::sourceNames() const
{ {
vector<string> names; return ranges::to<vector>(m_sources | ranges::views::keys);
for (auto const& s: m_sources)
names.push_back(s.first);
return names;
} }
map<string, unsigned> CompilerStack::sourceIndices() const map<string, unsigned> CompilerStack::sourceIndices() const