aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast/ASTJsonConverter.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-27 22:40:01 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-21 23:28:30 +0800
commite3f90565d8f623537072d84316d476343c2b06ad (patch)
tree44d2baeeed5e6c38577c743305e7f0234f8ea3cb /libsolidity/ast/ASTJsonConverter.h
parent4219acaba98b22d6c7b118682480b180e5196f46 (diff)
downloaddexon-solidity-e3f90565d8f623537072d84316d476343c2b06ad.tar.gz
dexon-solidity-e3f90565d8f623537072d84316d476343c2b06ad.tar.zst
dexon-solidity-e3f90565d8f623537072d84316d476343c2b06ad.zip
Avoid some Json copy operations.
Diffstat (limited to 'libsolidity/ast/ASTJsonConverter.h')
-rw-r--r--libsolidity/ast/ASTJsonConverter.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h
index 70e260db..cf41aa76 100644
--- a/libsolidity/ast/ASTJsonConverter.h
+++ b/libsolidity/ast/ASTJsonConverter.h
@@ -49,13 +49,16 @@ public:
);
/// Output the json representation of the AST to _stream.
void print(std::ostream& _stream, ASTNode const& _node);
- Json::Value toJson(ASTNode const& _node);
+ Json::Value&& toJson(ASTNode const& _node);
template <class T>
Json::Value toJson(std::vector<ASTPointer<T>> const& _nodes)
{
Json::Value ret(Json::arrayValue);
for (auto const& n: _nodes)
- ret.append(n ? toJson(*n) : Json::nullValue);
+ if (n)
+ appendMove(ret, toJson(*n));
+ else
+ ret.append(Json::nullValue);
return ret;
}
bool visit(SourceUnit const& _node) override;
@@ -155,6 +158,12 @@ private:
std::vector<std::pair<std::string, Json::Value>> &_attributes,
ExpressionAnnotation const& _annotation
);
+ static void appendMove(Json::Value& _array, Json::Value&& _value)
+ {
+ solAssert(_array.isArray(), "");
+ _array.append(std::move(_value));
+ }
+
bool m_legacy = false; ///< if true, use legacy format
bool m_inEvent = false; ///< whether we are currently inside an event or not
Json::Value m_currentValue;