From fd6353f40efc22e433e79b14aa0fabd2e68cabb9 Mon Sep 17 00:00:00 2001 From: Travis Downs Date: Thu, 14 Jul 2022 14:30:19 -0700 Subject: [PATCH] Add NOLINT to use of operator[] We already check the bounds so the cpp core guideline presumably does not apply and we don't want to pay the price for the additional bounds check inside at(). --- src/v/kafka/server/handlers/handler_interface.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/v/kafka/server/handlers/handler_interface.cc b/src/v/kafka/server/handlers/handler_interface.cc index 0551cef7ffb8..44593b0f96e4 100644 --- a/src/v/kafka/server/handlers/handler_interface.cc +++ b/src/v/kafka/server/handlers/handler_interface.cc @@ -128,6 +128,9 @@ constexpr auto make_lut(type_list) { std::optional handler_for_key(kafka::api_key key) noexcept { static constexpr auto lut = make_lut(request_types{}); if (key >= (short)0 && key < (short)lut.size()) { + // We have already checked the bounds above so it is safe to use [] + // instead of at() + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) if (auto handler = lut[key]) { return handler; }