From 237894cd451e1407c66340135f3846f2281e75dd Mon Sep 17 00:00:00 2001 From: map-per Date: Thu, 13 Nov 2025 17:27:21 +0100 Subject: [PATCH] switch to boost::regex and only construct regex once Signed-off-by: map-per --- libs/editor/xml_feature.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libs/editor/xml_feature.cpp b/libs/editor/xml_feature.cpp index 8813e851f..ea9a4caac 100644 --- a/libs/editor/xml_feature.cpp +++ b/libs/editor/xml_feature.cpp @@ -16,7 +16,7 @@ #include "base/timer.hpp" #include -#include +#include #include #include @@ -712,20 +712,21 @@ void XMLFeature::OSMBusinessReplacement(uint32_t old_type, uint32_t new_type) std::string name = GetTagValue("name"); // Remove OSM tags using the list from keys_to_remove.hpp - std::string regexPattern; + static const boost::regex regex([] { + std::string regexPattern; - for (auto const & key : kKeysToRemove) + for (auto const & key : kKeysToRemove) + { + if (!regexPattern.empty()) + regexPattern.append("|"); + regexPattern.append(key); + } + return regexPattern; + }()); + + ForEachTag([this](std::string_view key, std::string_view /*value*/) { - if (!regexPattern.empty()) - regexPattern.append("|"); - regexPattern.append(key); - } - - std::regex regex(regexPattern); - - ForEachTag([& regex, this](std::string_view key, std::string_view /*value*/) - { - if (std::regex_match(key.begin(), key.end(), regex)) + if (boost::regex_match(key.begin(), key.end(), regex)) RemoveTag(key); });