From e8f6e680d8b9816da9130ba3e3fd2e7f90994fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Fri, 29 Jul 2022 12:05:20 +0200 Subject: [PATCH 1/4] Add add function to work with strings --- Framework/Core/include/Framework/HistogramRegistry.h | 1 + Framework/Core/src/HistogramRegistry.cxx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Framework/Core/include/Framework/HistogramRegistry.h b/Framework/Core/include/Framework/HistogramRegistry.h index 4243c97781e64..e5b5ed37995e7 100644 --- a/Framework/Core/include/Framework/HistogramRegistry.h +++ b/Framework/Core/include/Framework/HistogramRegistry.h @@ -93,6 +93,7 @@ class HistogramRegistry HistPtr add(const HistogramSpec& histSpec); HistPtr add(char const* const name, char const* const title, const HistogramConfigSpec& histConfigSpec, bool callSumw2 = false); HistPtr add(char const* const name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); + HistPtr add(const std::string_view& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); template std::shared_ptr add(char const* const name, char const* const title, const HistogramConfigSpec& histConfigSpec, bool callSumw2 = false); diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index a5a5c74985b72..7fc7f2c0ae6b7 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -114,6 +114,11 @@ HistPtr HistogramRegistry::add(char const* const name, char const* const title, return insert({name, title, {histType, axes}, callSumw2}); } +HistPtr HistogramRegistry::add(const std::string_view& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2) +{ + return insert({name.data(), title, {histType, axes}, callSumw2}); +} + // store a copy of an existing histogram (or group of histograms) under a different name void HistogramRegistry::addClone(const std::string& source, const std::string& target) { From ea5657d690041f7d8f009f9786db1311d91f8e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 3 Aug 2022 09:57:41 +0200 Subject: [PATCH 2/4] Remove const& --- Framework/Core/include/Framework/HistogramRegistry.h | 2 +- Framework/Core/src/HistogramRegistry.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/HistogramRegistry.h b/Framework/Core/include/Framework/HistogramRegistry.h index e5b5ed37995e7..462a40bc49202 100644 --- a/Framework/Core/include/Framework/HistogramRegistry.h +++ b/Framework/Core/include/Framework/HistogramRegistry.h @@ -93,7 +93,7 @@ class HistogramRegistry HistPtr add(const HistogramSpec& histSpec); HistPtr add(char const* const name, char const* const title, const HistogramConfigSpec& histConfigSpec, bool callSumw2 = false); HistPtr add(char const* const name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); - HistPtr add(const std::string_view& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); + HistPtr add(std::string_view name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); template std::shared_ptr add(char const* const name, char const* const title, const HistogramConfigSpec& histConfigSpec, bool callSumw2 = false); diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index 7fc7f2c0ae6b7..92f520dedb747 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -114,7 +114,7 @@ HistPtr HistogramRegistry::add(char const* const name, char const* const title, return insert({name, title, {histType, axes}, callSumw2}); } -HistPtr HistogramRegistry::add(const std::string_view& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2) +HistPtr HistogramRegistry::add(std::string_view name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2) { return insert({name.data(), title, {histType, axes}, callSumw2}); } From b940bc7818ed3cdabf6904758c7ffdfe7c401374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 3 Aug 2022 10:14:33 +0200 Subject: [PATCH 3/4] Moving to string --- Framework/Core/include/Framework/HistogramRegistry.h | 2 +- Framework/Core/src/HistogramRegistry.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/HistogramRegistry.h b/Framework/Core/include/Framework/HistogramRegistry.h index 462a40bc49202..97a65a5b29f7a 100644 --- a/Framework/Core/include/Framework/HistogramRegistry.h +++ b/Framework/Core/include/Framework/HistogramRegistry.h @@ -93,7 +93,7 @@ class HistogramRegistry HistPtr add(const HistogramSpec& histSpec); HistPtr add(char const* const name, char const* const title, const HistogramConfigSpec& histConfigSpec, bool callSumw2 = false); HistPtr add(char const* const name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); - HistPtr add(std::string_view name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); + HistPtr add(const std::string& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2 = false); template std::shared_ptr add(char const* const name, char const* const title, const HistogramConfigSpec& histConfigSpec, bool callSumw2 = false); diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index 92f520dedb747..3a9689c8617c8 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -114,7 +114,7 @@ HistPtr HistogramRegistry::add(char const* const name, char const* const title, return insert({name, title, {histType, axes}, callSumw2}); } -HistPtr HistogramRegistry::add(std::string_view name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2) +HistPtr HistogramRegistry::add(const std::string& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2) { return insert({name.data(), title, {histType, axes}, callSumw2}); } From e73e483755d5869c3773c8c09a45956e967b3270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 3 Aug 2022 10:16:46 +0200 Subject: [PATCH 4/4] avoid .data() --- Framework/Core/src/HistogramRegistry.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index 3a9689c8617c8..5bc73e0a63a3c 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -116,7 +116,7 @@ HistPtr HistogramRegistry::add(char const* const name, char const* const title, HistPtr HistogramRegistry::add(const std::string& name, char const* const title, HistType histType, const std::vector& axes, bool callSumw2) { - return insert({name.data(), title, {histType, axes}, callSumw2}); + return insert({name.c_str(), title, {histType, axes}, callSumw2}); } // store a copy of an existing histogram (or group of histograms) under a different name