From d99893068b3266c47f45ebc21e1ae55bff091127 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 16 Oct 2026 13:44:25 +0200 Subject: [PATCH] DPL: hoist filter::view lambda --- .../Core/include/Framework/AnalysisTask.h | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisTask.h b/Framework/Core/include/Framework/AnalysisTask.h index dcef106c563e4..48a189f241cf0 100644 --- a/Framework/Core/include/Framework/AnalysisTask.h +++ b/Framework/Core/include/Framework/AnalysisTask.h @@ -75,6 +75,17 @@ concept is_table_iterator_or_enumeration = soa::is_table_or_iterator || is_en // the contents of an AnalysisTask... namespace { +// One closure type for every argument index. Written inline inside the pack +// expansion in bindAssociatedTables() below, the predicate lambda would get a +// fresh closure type per Args, and with it its own std::ranges::filter_view, +// __bind_back and __perfect_forward_impl instantiation -- paid once per +// associated table per process function. Taking the index as a runtime capture +// instead lets every call site share a single filter_view specialisation. +inline auto matchersForArgument(int argumentIndex) +{ + return std::views::filter([argumentIndex](auto const& pair) { return pair.first == argumentIndex; }); +} + struct AnalysisDataProcessorBuilder { template static void addGroupingCandidates(Cache& bk, Cache& bku, bool enabled) @@ -286,7 +297,7 @@ struct AnalysisDataProcessorBuilder { requires(!std::same_as) { constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId(); - return extract, 0>(record, matchers | std::views::filter([](auto const& pair) { return pair.first == 0; }), infos, hash); + return extract, 0>(record, matchers | matchersForArgument(0), infos, hash); } template @@ -294,7 +305,7 @@ struct AnalysisDataProcessorBuilder { requires(!std::same_as && sizeof...(Args) > 0) { constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId(); - return std::make_tuple(extract, has_type_at_v(pack{}) + 1>(record, matchers | std::views::filter([](auto const& pair) { return pair.first == has_type_at_v(pack{}) + 1; }), infos, hash)...); + return std::make_tuple(extract, has_type_at_v(pack{}) + 1>(record, matchers | matchersForArgument(has_type_at_v(pack{}) + 1), infos, hash)...); } template @@ -595,8 +606,7 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args) // replace origins in Preslice declarations homogeneous_apply_refs_sized([&newOrigin](auto& element) { return analysis_task_parsers::replaceOrigin(element, newOrigin); }, *task.get()); - auto algo = AlgorithmSpec::InitCallback - { + auto algo = AlgorithmSpec::InitCallback{ [task = task, expressionInfos, inputInfos, newOrigin, newOriginStr](InitContext& ic) mutable { Cache bindingsKeys; Cache bindingsKeysUnsorted; @@ -715,8 +725,7 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args) // finalize outputs homogeneous_apply_refs_sized([&pc](auto& element) { return analysis_task_parsers::finalizeOutput(pc, element); }, *task.get()); }; - } - }; + }}; return { name,