mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Add configure option for preallocating PortVal objects
This commit is contained in:
parent
aa3053db00
commit
4f902c0f39
5 changed files with 41 additions and 0 deletions
15
src/Val.cc
15
src/Val.cc
|
@ -3977,6 +3977,17 @@ ValManager::ValManager()
|
|||
|
||||
for ( auto i = 0u; i < PREALLOCATED_INTS; ++i )
|
||||
ints[i] = Val::MakeInt(PREALLOCATED_INT_LOWEST + i);
|
||||
|
||||
#ifdef PREALLOCATE_PORT_ARRAY
|
||||
for ( auto i = 0u; i < ports.size(); ++i )
|
||||
{
|
||||
auto& arr = ports[i];
|
||||
auto port_type = static_cast<TransportProto>(i);
|
||||
|
||||
for ( auto j = 0u; j < arr.size(); ++j )
|
||||
arr[j] = make_intrusive<PortVal>(PortVal::Mask(j, port_type));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const PortValPtr& ValManager::Port(uint32_t port_num, TransportProto port_type)
|
||||
|
@ -3988,10 +3999,14 @@ const PortValPtr& ValManager::Port(uint32_t port_num, TransportProto port_type)
|
|||
}
|
||||
|
||||
auto port_masked = PortVal::Mask(port_num, port_type);
|
||||
#ifdef PREALLOCATE_PORT_ARRAY
|
||||
return ports[port_type][port_num];
|
||||
#else
|
||||
if ( ports.count(port_masked) == 0 )
|
||||
ports.insert({port_masked, make_intrusive<PortVal>(port_masked)});
|
||||
|
||||
return ports[port_masked];
|
||||
#endif
|
||||
}
|
||||
|
||||
const PortValPtr& ValManager::Port(uint32_t port_num)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue