From 3072d4eb13663aa68d547b28cbc0f44e1d7212a3 Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Wed, 14 Feb 2024 22:39:02 +0100 Subject: [PATCH] Fix globToRegex and put it in anonymous namespace --- .../RecoTau/plugins/DQMHistNormalizer.cc | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Validation/RecoTau/plugins/DQMHistNormalizer.cc b/Validation/RecoTau/plugins/DQMHistNormalizer.cc index 9283aa9aa52fa..999cc5ac850fb 100644 --- a/Validation/RecoTau/plugins/DQMHistNormalizer.cc +++ b/Validation/RecoTau/plugins/DQMHistNormalizer.cc @@ -25,22 +25,23 @@ using namespace std; -// Three implementations were tested: char-by-char (this version), -// using std::string::find + std::string::replace and std::regex_replace. -// First one takes ~60 ns per iteration, second one ~85 ns, -// and the regex implementation takes nearly 1 us -std::string globToRegex(const std::string& s) { - std::string out; - out.reserve(s.size()); - for (auto ch : s) { - if (ch == '*') { - out.push_back('.'); - out.push_back('*'); +namespace { + // Three implementations were tested: char-by-char (this version), + // using std::string::find + std::string::replace and std::regex_replace. + // First one takes ~60 ns per iteration, second one ~85 ns, + // and the regex implementation takes nearly 1 us + std::string globToRegex(const std::string& s) { + std::string out; + out.reserve(s.size()); + for (auto ch : s) { + if (ch == '*') { + out.push_back('.'); + } + out.push_back(ch); } - out.push_back(ch); + return out; } - return out; -} +} // namespace class DQMHistNormalizer : public edm::one::EDAnalyzer { public: