diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 2187faa4df93b..5349cd9dc5233 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -2016,35 +2017,38 @@ template using with_common_getter_t = typename std::conditional || dynamic_with_common_getter, std::true_type, std::false_type>::type; template C> -ColumnGetterFunction createGetterPtr(const std::string_view& columnLabel, bool& found) +ColumnGetterFunction createGetterPtr(const std::string_view& columnLabel) { - if (std::strcmp(columnLabel.data(), C::columnLabel()) == 0) { - found = true; + const size_t n = columnLabel.size(); + + if(n == 0 || n != strlen(C::columnLabel())) { + return nullptr; } - return &getColumnValue; + return (std::strncmp(columnLabel.data(), C::columnLabel(), n)) ? nullptr : &getColumnValue; } template C> -ColumnGetterFunction createGetterPtr(const std::string_view& columnLabel, bool& found) +ColumnGetterFunction createGetterPtr(const std::string_view& columnLabel) { - if (std::strcmp(&columnLabel[1], C::columnLabel()) == 0 || std::strcmp(columnLabel.data(), C::columnLabel()) == 0) { - found = true; + const size_t n = columnLabel.size(); + + if(n == 0 || n != strlen(C::columnLabel())) { + return nullptr; } - return &getColumnValue; + return ((std::strncmp(&columnLabel[1], C::columnLabel(), n-1) && std::strncmp(columnLabel.data(), C::columnLabel(), n))) ? nullptr : &getColumnValue; } template ColumnGetterFunction getColumnGetterByLabel(o2::framework::pack, const std::string_view& columnLabel) { - bool found = false; ColumnGetterFunction func; - (void)((func = createGetterPtr(columnLabel, found), found) || ...); + (void)((func = createGetterPtr(columnLabel), func) || ...); - if (!found) { - throw std::runtime_error("Getter for provided columnLabel not found!"); + if (!func) { + throw framework::runtime_error("Getter for provided columnLabel not found!"); } return func;