Skip to content

Reduce dynamic allocation in functor/filtering code

Olli Lupton requested to merge olupton_reduce_dynamic_allocation into master

In the course of opening LHCb!2472 (merged) I noticed some functor/filter code was showing up. This uses LHCb!2475 (merged) to remove some dynamic allocation, and makes some drive-by code-consistency changes in the core functor code.

Before:

  • auto prepared = m_functor.prepare() would cause a dynamic allocation in the std::function type of prepared
  • Using Pr::Filter<some_zip> puts two objects on the TES, a non-owning zip view and an owning container of unspecified type. The latter used std::make_unique so that its address is stable and the non-owning view could refer to it.

Now:

  • The prepared functor type is an allocator-aware type, not std::function
  • A custom allocator/deleter is used instead of the default std::unique_ptr<T> allocator/deleter

Depends on LHCb!2475 (merged), needs Phys!715 (merged).

cc: @nnolte

Edited by Olli Lupton

Merge request reports