mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Modifiable: No virtual destructor
There's only three classes that inherit from Modifiable today. The virtual destructor adds an extra 8 byte vtable to every instance of table, record or vector values. Calling Unregister() explicitly from the destructors explicitly saves 8 bytes of memory for each instance.
This commit is contained in:
parent
5e9dad04db
commit
00ad3e31c6
3 changed files with 18 additions and 7 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "zeek/IPAddr.h"
|
||||
#include "zeek/IntrusivePtr.h"
|
||||
#include "zeek/NetVar.h"
|
||||
#include "zeek/Notifier.h"
|
||||
#include "zeek/Overflow.h"
|
||||
#include "zeek/PrefixTable.h"
|
||||
#include "zeek/RE.h"
|
||||
|
@ -1712,6 +1713,8 @@ void TableVal::Init(TableTypePtr t, bool ordered) {
|
|||
}
|
||||
|
||||
TableVal::~TableVal() {
|
||||
notifier::detail::Modifiable::Unregister();
|
||||
|
||||
if ( timer )
|
||||
detail::timer_mgr->Cancel(timer);
|
||||
|
||||
|
@ -2952,6 +2955,8 @@ RecordVal::RecordVal(RecordTypePtr t, std::vector<std::optional<ZVal>> init_vals
|
|||
}
|
||||
|
||||
RecordVal::~RecordVal() {
|
||||
notifier::detail::Modifiable::Unregister();
|
||||
|
||||
auto n = record_val.size();
|
||||
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
|
@ -3234,6 +3239,8 @@ VectorVal::VectorVal(VectorTypePtr t, std::vector<std::optional<ZVal>>* vals) :
|
|||
}
|
||||
|
||||
VectorVal::~VectorVal() {
|
||||
notifier::detail::Modifiable::Unregister();
|
||||
|
||||
if ( yield_types ) {
|
||||
int n = yield_types->size();
|
||||
for ( auto i = 0; i < n; ++i ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue