switch to boost::regex and only construct regex once

Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
map-per
2025-11-13 17:27:21 +01:00
parent 323b49388d
commit 237894cd45

View File

@@ -16,7 +16,7 @@
#include "base/timer.hpp"
#include <array>
#include <regex>
#include <boost/regex.hpp>
#include <sstream>
#include <string>
@@ -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);
});