packet_analysis/Dispatcher: Do not index table twice

It's okay to return the nullptr that's in the table, no need to check
for != nullptr before dereferencing again.
This commit is contained in:
Arne Welzel 2023-11-01 10:10:15 +01:00
parent e56ef0fd9b
commit 9bebd93c06

View file

@ -50,7 +50,7 @@ void Dispatcher::Register(uint32_t identifier, AnalyzerPtr analyzer) {
const AnalyzerPtr& Dispatcher::Lookup(uint32_t identifier) const { const AnalyzerPtr& Dispatcher::Lookup(uint32_t identifier) const {
int64_t index = identifier - lowest_identifier; int64_t index = identifier - lowest_identifier;
if ( index >= 0 && index < static_cast<int64_t>(table.size()) && table[index] != nullptr ) if ( index >= 0 && index < static_cast<int64_t>(table.size()) )
return table[index]; return table[index];
return Analyzer::nil; return Analyzer::nil;