mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
script optimization support for clearing tables/vectors using "delete"
This commit is contained in:
parent
ce6d77e2ce
commit
74d36eb759
6 changed files with 37 additions and 8 deletions
|
@ -159,6 +159,15 @@ void CPPCompile::GenAddStmt(const ExprStmt* es) {
|
|||
|
||||
void CPPCompile::GenDeleteStmt(const ExprStmt* es) {
|
||||
auto op = es->StmtExpr();
|
||||
|
||||
if ( op->Tag() == EXPR_NAME ) {
|
||||
if ( op->GetType()->Tag() == TYPE_TABLE )
|
||||
Emit("%s->RemoveAll();", GenExpr(op, GEN_VAL_PTR));
|
||||
else
|
||||
Emit("%s->Resize(0);", GenExpr(op, GEN_VAL_PTR));
|
||||
return;
|
||||
}
|
||||
|
||||
auto aggr = op->GetOp1();
|
||||
auto aggr_gen = GenExpr(aggr, GEN_VAL_PTR);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue