From 9bebd93c067a22d796f40f63e7be17b310f34eaf Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Wed, 1 Nov 2023 10:10:15 +0100 Subject: [PATCH] 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. --- src/packet_analysis/Dispatcher.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packet_analysis/Dispatcher.cc b/src/packet_analysis/Dispatcher.cc index 418d4fbb9f..f39c30189a 100644 --- a/src/packet_analysis/Dispatcher.cc +++ b/src/packet_analysis/Dispatcher.cc @@ -50,7 +50,7 @@ void Dispatcher::Register(uint32_t identifier, AnalyzerPtr analyzer) { const AnalyzerPtr& Dispatcher::Lookup(uint32_t identifier) const { int64_t index = identifier - lowest_identifier; - if ( index >= 0 && index < static_cast(table.size()) && table[index] != nullptr ) + if ( index >= 0 && index < static_cast(table.size()) ) return table[index]; return Analyzer::nil;