Optimize record constructor expression.

We remove the inheritance from UnaryExpression because we know the
type of the operand precisely and can skip a temporary when evaluating
the expression.

#425
This commit is contained in:
Robin Sommer 2020-10-02 14:17:43 +00:00
parent d782c60f19
commit e9aa531b83
2 changed files with 37 additions and 8 deletions

View file

@ -630,16 +630,25 @@ protected:
int field;
};
class RecordConstructorExpr final : public UnaryExpr {
class RecordConstructorExpr final : public Expr {
public:
explicit RecordConstructorExpr(ListExprPtr constructor_list);
~RecordConstructorExpr() override;
ListExpr* Op() const { return op.get(); }
ValPtr Eval(Frame* f) const override;
bool IsPure() const override;
TraversalCode Traverse(TraversalCallback* cb) const override;
protected:
ValPtr InitVal(const zeek::Type* t, ValPtr aggr) const override;
ValPtr Fold(Val* v) const override;
void ExprDescribe(ODesc* d) const override;
ListExprPtr op;
};
class TableConstructorExpr final : public UnaryExpr {