From 52f801b77ebdf1b927451fed1e640331366e029a Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:09:26 +0100 Subject: [PATCH] DPL: improve getIndexFromLabel Avoids extra string creation. --- Framework/Core/include/Framework/ASoA.h | 2 +- Framework/Core/src/ASoA.cxx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 7b0b69ec8941f..0a5092bbd0959 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1619,7 +1619,7 @@ auto select(T const& t, framework::expressions::Filter const& f) return Filtered({t.asArrowTable()}, selectionToVector(framework::expressions::createSelection(t.asArrowTable(), f))); } -arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, const char* label); +arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, std::string_view label); template consteval auto base_iter(framework::pack&&) -> TableIterator diff --git a/Framework/Core/src/ASoA.cxx b/Framework/Core/src/ASoA.cxx index 38a6750a90dbe..a37d0f33891e7 100644 --- a/Framework/Core/src/ASoA.cxx +++ b/Framework/Core/src/ASoA.cxx @@ -123,10 +123,19 @@ std::shared_ptr ArrowHelpers::concatTables(std::vectorschema()->fields().begin(), table->schema()->fields().end(), [&](std::shared_ptr const& f) { - return o2::framework::strToUpper(label) == o2::framework::strToUpper(std::string{f->name()}); + auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string& str2) { + return std::ranges::equal( + str1, str2, + [](char c1, char c2) { + return std::tolower(static_cast(c1)) == + std::tolower(static_cast(c2)); + }); + }; + + return caseInsensitiveCompare(label, f->name()); }); if (field == table->schema()->fields().end()) { o2::framework::throw_error(o2::framework::runtime_error_f("Unable to find column with label %s", label));