From 91f05f19ef77abab8d83c7102609dd9c0ea59d03 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Tue, 24 Mar 2020 13:06:58 -0700 Subject: [PATCH] Don't allocate a value during a loop if avoidable --- src/Expr.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Expr.cc b/src/Expr.cc index e7a83385b8..25561a18da 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -2240,7 +2240,6 @@ bool AssignExpr::TypeCheckArithmetics(TypeTag bt1, TypeTag bt2) { Warn("dangerous assignment of integer to count"); op2 = make_intrusive(std::move(op2), bt1); - bt2 = op2->Type()->Tag(); } // Assignment of count to counter or vice @@ -3658,6 +3657,8 @@ IntrusivePtr RecordCoerceExpr::InitVal(const BroType* t, IntrusivePtr IntrusivePtr RecordCoerceExpr::Fold(Val* v) const { auto val = make_intrusive(Type()->AsRecordType()); + RecordType* val_type = val->Type()->AsRecordType(); + RecordVal* rv = v->AsRecordVal(); for ( int i = 0; i < map_size; ++i ) @@ -3685,7 +3686,6 @@ IntrusivePtr RecordCoerceExpr::Fold(Val* v) const } BroType* rhs_type = rhs->Type(); - RecordType* val_type = val->Type()->AsRecordType(); BroType* field_type = val_type->FieldType(i); if ( rhs_type->Tag() == TYPE_RECORD &&