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

@ -665,11 +665,11 @@ void Analyzer::ProtocolConfirmation(Tag arg_tag)
EnumVal* tval = arg_tag ? arg_tag.AsEnumVal() : tag.AsEnumVal();
Ref(tval);
val_list* vl = new val_list;
vl->append(BuildConnVal());
vl->append(tval);
vl->append(val_mgr->GetCount(id));
mgr.QueueEvent(protocol_confirmation, vl);
mgr.QueueEvent(protocol_confirmation, {
BuildConnVal(),
tval,
val_mgr->GetCount(id),
});
protocol_confirmed = true;
}
@ -692,12 +692,12 @@ void Analyzer::ProtocolViolation(const char* reason, const char* data, int len)
EnumVal* tval = tag.AsEnumVal();
Ref(tval);
val_list* vl = new val_list;
vl->append(BuildConnVal());
vl->append(tval);
vl->append(val_mgr->GetCount(id));
vl->append(r);
mgr.QueueEvent(protocol_violation, vl);
mgr.QueueEvent(protocol_violation, {
BuildConnVal(),
tval,
val_mgr->GetCount(id),
r,
});
}
void Analyzer::AddTimer(analyzer_timer_func timer, double t,
@ -782,6 +782,11 @@ void Analyzer::ConnectionEvent(EventHandlerPtr f, val_list* vl)
conn->ConnectionEvent(f, this, vl);
}
void Analyzer::ConnectionEvent(EventHandlerPtr f, val_list vl)
{
conn->ConnectionEvent(f, this, std::move(vl));
}
void Analyzer::Weird(const char* name, const char* addl)
{
conn->Weird(name, addl);