From 982ed7caf07e10de6d0cfc9909b66e49c66561b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 24 Feb 2022 09:48:12 +0100 Subject: [PATCH] Don't Needlessly Capture Constant Buffer Size A lambda expression can read the value of a variable without capturing it if the variable has const non-volatile integral or enumeration type and has been initialized with a constant expression Clang issues a diagnostic if such variables are captured so drop the 'sz' from the explicit list of captures. --- src/opm/output/data/InterRegFlowMap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/opm/output/data/InterRegFlowMap.cpp b/src/opm/output/data/InterRegFlowMap.cpp index 551e75969..59bbac2d4 100644 --- a/src/opm/output/data/InterRegFlowMap.cpp +++ b/src/opm/output/data/InterRegFlowMap.cpp @@ -367,7 +367,7 @@ void Opm::data::InterRegFlowMap::CSR::condenseDuplicates() void Opm::data::InterRegFlowMap::CSR::accumulateFlowRates(const RateBuffer& v) { - const auto sz = Window::bufferSize(); + constexpr auto sz = Window::bufferSize(); if (v.size() != this->compressedIdx_.size()*sz) { throw std::logic_error { @@ -375,14 +375,14 @@ void Opm::data::InterRegFlowMap::CSR::accumulateFlowRates(const RateBuffer& v) }; } - auto dst = [this, sz](const Offset start) -> Window + auto dst = [this](const Offset start) -> Window { auto begin = this->sa_.begin() + start*sz; return Window { begin, begin + sz }; }; - auto src = [&v, sz](const Offset start) -> ReadOnlyWindow + auto src = [&v](const Offset start) -> ReadOnlyWindow { auto begin = v.begin() + start*sz;