Make HTML entity map static.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Drastically reduces allocations.
This commit is contained in:
parent
8b5c0d289e
commit
51f8422929
|
@ -43,7 +43,7 @@ std::string unescape_html(const std::string_view html)
|
|||
|
||||
// Source: https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_
|
||||
// entity_references#Character_entity_references_in_HTML
|
||||
const std::map<std::string_view, char32_t>
|
||||
static const std::map<std::string_view, char32_t>
|
||||
names{{"exclamation", 0x0021}, {"quot", 0x0022}, {"percent", 0x0025},
|
||||
{"amp", 0x0026}, {"apos", 0x0027}, {"add", 0x002B},
|
||||
{"lt", 0x003C}, {"equal", 0x003D}, {"gt", 0x003E},
|
||||
|
@ -150,7 +150,7 @@ std::string unescape_html(const std::string_view html)
|
|||
try
|
||||
{
|
||||
const char32_t codepoint{
|
||||
[&match, &names]
|
||||
[&match]
|
||||
{
|
||||
// If it doesn't start with a '#' it is a named entity.
|
||||
if (match[1].str()[0] != '#')
|
||||
|
|
Loading…
Reference in New Issue
Block a user