mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Adjust memory management for &default argument expression type-check
Mainly, there was an extra Ref(). In theory, the front-insertion was also not efficient.
This commit is contained in:
parent
fe8db7f150
commit
d4ae5c5fbc
1 changed files with 6 additions and 5 deletions
11
src/Expr.cc
11
src/Expr.cc
|
@ -5277,7 +5277,7 @@ bool check_and_promote_args(ListExpr* const args, RecordType* types)
|
||||||
|
|
||||||
if ( el.length() < ntypes )
|
if ( el.length() < ntypes )
|
||||||
{
|
{
|
||||||
ExprPList def_elements;
|
std::vector<ExprPtr> def_elements;
|
||||||
|
|
||||||
// Start from rightmost parameter, work backward to fill in missing
|
// Start from rightmost parameter, work backward to fill in missing
|
||||||
// arguments using &default expressions.
|
// arguments using &default expressions.
|
||||||
|
@ -5300,12 +5300,13 @@ bool check_and_promote_args(ListExpr* const args, RecordType* types)
|
||||||
// separately for each instance, rather than
|
// separately for each instance, rather than
|
||||||
// one instance inheriting the transformed version
|
// one instance inheriting the transformed version
|
||||||
// from another.
|
// from another.
|
||||||
auto e = def_attr->GetExpr();
|
const auto& e = def_attr->GetExpr();
|
||||||
def_elements.push_front(e->Duplicate().release());
|
def_elements.emplace_back(e->Duplicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const auto& elem : def_elements )
|
auto ne = def_elements.size();
|
||||||
el.push_back(elem->Ref());
|
while ( ne )
|
||||||
|
el.push_back(def_elements[--ne].release());
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeList* tl = new TypeList();
|
TypeList* tl = new TypeList();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue