mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
packet_analysis: Avoid shared_ptr copying for analyzer lookups
For deeply encapsulated connections (think AWS traffic mirroring format like IP,UDP,GENEVE,IP,UDP,VXLAN,ETH,IP,TCP), the Dispatcher::Lookup() method is fairly visible in profiles when running in bare mode. This changes the Analyzer::Lookup() and Dispatcher::Lookup() return value breaking the API in favor of the performance improvement. Relates to zeek/zeek#3379.
This commit is contained in:
parent
a821604505
commit
e56ef0fd9b
5 changed files with 56 additions and 33 deletions
|
@ -48,12 +48,12 @@ void Dispatcher::Register(uint32_t identifier, AnalyzerPtr analyzer) {
|
|||
table[index] = std::move(analyzer);
|
||||
}
|
||||
|
||||
AnalyzerPtr Dispatcher::Lookup(uint32_t identifier) const {
|
||||
const AnalyzerPtr& Dispatcher::Lookup(uint32_t identifier) const {
|
||||
int64_t index = identifier - lowest_identifier;
|
||||
if ( index >= 0 && index < static_cast<int64_t>(table.size()) && table[index] != nullptr )
|
||||
return table[index];
|
||||
|
||||
return nullptr;
|
||||
return Analyzer::nil;
|
||||
}
|
||||
|
||||
size_t Dispatcher::Count() const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue