From e6aad7bfa7fcb6158e756addf1db3f5ae5b3d45f Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:11:32 +0100 Subject: [PATCH] Out of line ProgOption::SetProperty for int and std::string The specializations are common enough to show up in O2 compilation profiles and they are not time critical (once per run at max). --- fairmq/ProgOptions.cxx | 3 +++ fairmq/ProgOptions.h | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fairmq/ProgOptions.cxx b/fairmq/ProgOptions.cxx index a6282c4d..ba13a8c3 100644 --- a/fairmq/ProgOptions.cxx +++ b/fairmq/ProgOptions.cxx @@ -448,3 +448,6 @@ void ProgOptions::PrintOptionsRaw() const } } // namespace fair::mq + +template void fair::mq::ProgOptions::SetProperty(const std::string& key, std::string val); +template void fair::mq::ProgOptions::SetProperty(const std::string& key, int val); diff --git a/fairmq/ProgOptions.h b/fairmq/ProgOptions.h index 6d367fef..f6eea35d 100644 --- a/fairmq/ProgOptions.h +++ b/fairmq/ProgOptions.h @@ -129,17 +129,7 @@ class ProgOptions /// @param key /// @param val template - void SetProperty(const std::string& key, T val) - { - std::unique_lock lock(fMtx); - - SetVarMapValue::type>(key, val); - - lock.unlock(); - - fEvents.Emit::type>(key, val); - fEvents.Emit(key, GetPropertyAsString(key)); - } + void SetProperty(const std::string& key, T val); /// @brief Updates an existing config property (or fails if it doesn't exist) /// @param key @@ -275,5 +265,20 @@ class ProgOptions }; } // namespace fair::mq +template +void fair::mq::ProgOptions::SetProperty(const std::string& key, T val) +{ + std::unique_lock lock(fMtx); + + SetVarMapValue::type>(key, val); + + lock.unlock(); + + fEvents.Emit::type>(key, val); + fEvents.Emit(key, GetPropertyAsString(key)); +} + +extern template void fair::mq::ProgOptions::SetProperty(const std::string& key, int val); +extern template void fair::mq::ProgOptions::SetProperty(const std::string& key, std::string val); #endif /* FAIR_MQ_PROGOPTIONS_H */