Skip to content

Commit

Permalink
Avoid unnecessary temporary value when coercing a record that's alrea…
Browse files Browse the repository at this point in the history
…dy the right type.

The combination of this commit with the previous one now lets the
examples in #425 all execute with the same performance.

Closes #425.
  • Loading branch information
rsmmr committed Oct 5, 2020
1 parent e9aa531 commit 553ce28
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Expr.cc
Expand Up @@ -3758,6 +3758,9 @@ ValPtr RecordCoerceExpr::InitVal(const zeek::Type* t, ValPtr aggr) const

ValPtr RecordCoerceExpr::Fold(Val* v) const
{
if ( same_type(GetType(), Op()->GetType()) )
return IntrusivePtr{NewRef{}, v};

auto val = make_intrusive<RecordVal>(GetType<RecordType>());
RecordType* val_type = val->GetType()->AsRecordType();

Expand Down

0 comments on commit 553ce28

Please sign in to comment.