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:
Jon Siwek 2019-04-11 19:02:13 -07:00
parent 78dcbcc71a
commit 8bc65f09ec
92 changed files with 1585 additions and 1679 deletions

View file

@ -715,11 +715,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
// Raise the log event.
if ( stream->event )
{
val_list* vl = new val_list(1);
vl->append(columns->Ref());
mgr.QueueEvent(stream->event, vl, SOURCE_LOCAL);
}
mgr.QueueEvent(stream->event, {columns->Ref()}, SOURCE_LOCAL);
// Send to each of our filters.
for ( list<Filter*>::iterator i = stream->filters.begin();
@ -732,8 +728,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
{
// See whether the predicates indicates that we want
// to log this record.
val_list vl(1);
vl.append(columns->Ref());
val_list vl{columns->Ref()};
int result = 1;
@ -750,17 +745,12 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
if ( filter->path_func )
{
val_list vl(3);
vl.append(id->Ref());
Val* path_arg;
if ( filter->path_val )
path_arg = filter->path_val->Ref();
else
path_arg = val_mgr->GetEmptyString();
vl.append(path_arg);
Val* rec_arg;
BroType* rt = filter->path_func->FType()->Args()->FieldType("rec");
@ -770,7 +760,11 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
// Can be TYPE_ANY here.
rec_arg = columns->Ref();
vl.append(rec_arg);
val_list vl{
id->Ref(),
path_arg,
rec_arg,
};
Val* v = 0;
@ -1087,8 +1081,7 @@ threading::Value** Manager::RecordToFilterVals(Stream* stream, Filter* filter,
RecordVal* ext_rec = nullptr;
if ( filter->num_ext_fields > 0 )
{
val_list vl(1);
vl.append(filter->path_val->Ref());
val_list vl{filter->path_val->Ref()};
Val* res = filter->ext_func->Call(&vl);
if ( res )
ext_rec = res->AsRecordVal();
@ -1593,8 +1586,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
assert(func);
// Call the postprocessor function.
val_list vl(1);
vl.append(info);
val_list vl{info};
int result = 0;