From 040bf53c77c67b8ccdb493ab711301fc649f53ab Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 18 Jan 2022 14:26:38 +0000 Subject: Use C++11-style initialisation for the entity map in httpd_stats. --- src/modules/m_httpd_stats.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'src/modules/m_httpd_stats.cpp') diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index f5e3b8427..74f0ef8aa 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -39,23 +39,13 @@ static ISupport::EventProvider* isevprov; namespace Stats { - struct Entities final - { - static const insp::flat_map& entities; + static const insp::flat_map& xmlentities = { + { '<', "lt" }, + { '>', "gt" }, + { '&', "amp" }, + { '"', "quot" }, }; - static const insp::flat_map& init_entities() - { - static insp::flat_map entities; - entities['<'] = "lt"; - entities['>'] = "gt"; - entities['&'] = "amp"; - entities['"'] = "quot"; - return entities; - } - - const insp::flat_map& Entities::entities = init_entities(); - std::string Sanitize(const std::string& str) { std::string ret; @@ -63,8 +53,8 @@ namespace Stats for (const auto& chr : str) { - insp::flat_map::const_iterator it = Entities::entities.find(chr); - if (it != Entities::entities.end()) + insp::flat_map::const_iterator it = xmlentities.find(chr); + if (it != xmlentities.end()) { ret += '&'; ret += it->second; -- cgit v1.3.1-10-gc9f91