mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Cleanup/improve PList usage and Event API
Majority of PLists are now created as automatic/stack objects, rather than on heap and initialized either with the known-capacity reserved upfront or directly from an initializer_list (so there's no wasted slack in the memory that gets allocated for lists containing a fixed/known number of elements). Added versions of the ConnectionEvent/QueueEvent methods that take a val_list by value. Added a move ctor/assign-operator to Plists to allow passing them around without having to copy the underlying array of pointers.
This commit is contained in:
parent
78dcbcc71a
commit
8bc65f09ec
92 changed files with 1585 additions and 1679 deletions
20
src/Stmt.cc
20
src/Stmt.cc
|
@ -292,13 +292,14 @@ Val* PrintStmt::DoExec(val_list* vals, stmt_flow_type& /* flow */) const
|
|||
|
||||
if ( print_hook )
|
||||
{
|
||||
val_list* vl = new val_list(2);
|
||||
::Ref(f);
|
||||
vl->append(new Val(f));
|
||||
vl->append(new StringVal(d.Len(), d.Description()));
|
||||
|
||||
// Note, this doesn't do remote printing.
|
||||
mgr.Dispatch(new Event(print_hook, vl), true);
|
||||
mgr.Dispatch(
|
||||
new Event(
|
||||
print_hook,
|
||||
{new Val(f), new StringVal(d.Len(), d.Description())}),
|
||||
true);
|
||||
}
|
||||
|
||||
if ( remote_serializer )
|
||||
|
@ -704,7 +705,7 @@ bool Case::DoUnserialize(UnserialInfo* info)
|
|||
if ( ! UNSERIALIZE(&len) )
|
||||
return false;
|
||||
|
||||
type_cases = new id_list;
|
||||
type_cases = new id_list(len);
|
||||
|
||||
while ( len-- )
|
||||
{
|
||||
|
@ -1198,7 +1199,10 @@ Val* EventStmt::Exec(Frame* f, stmt_flow_type& flow) const
|
|||
val_list* args = eval_list(f, event_expr->Args());
|
||||
|
||||
if ( args )
|
||||
mgr.QueueEvent(event_expr->Handler(), args);
|
||||
{
|
||||
mgr.QueueEvent(event_expr->Handler(), std::move(*args));
|
||||
delete args;
|
||||
}
|
||||
|
||||
flow = FLOW_NEXT;
|
||||
|
||||
|
@ -1633,7 +1637,7 @@ bool ForStmt::DoUnserialize(UnserialInfo* info)
|
|||
if ( ! UNSERIALIZE(&len) )
|
||||
return false;
|
||||
|
||||
loop_vars = new id_list;
|
||||
loop_vars = new id_list(len);
|
||||
|
||||
while ( len-- )
|
||||
{
|
||||
|
@ -2149,7 +2153,7 @@ bool InitStmt::DoUnserialize(UnserialInfo* info)
|
|||
if ( ! UNSERIALIZE(&len) )
|
||||
return false;
|
||||
|
||||
inits = new id_list;
|
||||
inits = new id_list(len);
|
||||
|
||||
while ( len-- )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue