diff --git a/Source/cmDocumentationFormatterHTML.cxx b/Source/cmDocumentationFormatterHTML.cxx
index 175bc8d68..7422ef458 100644
--- a/Source/cmDocumentationFormatterHTML.cxx
+++ b/Source/cmDocumentationFormatterHTML.cxx
@@ -32,11 +32,14 @@ static bool cmDocumentationIsHyperlinkChar(char c)
static void cmDocumentationPrintHTMLChar(std::ostream& os, char c)
{
// Use an escape sequence if necessary.
- std::map escapes;
- escapes['<'] = "<";
- escapes['>'] = ">";
- escapes['&'] = "&";
- escapes['\n'] = "
";
+ static std::map escapes;
+ if (escapes.empty())
+ {
+ escapes['<'] = "<";
+ escapes['>'] = ">";
+ escapes['&'] = "&";
+ escapes['\n'] = "
";
+ }
if (escapes.find(c) == escapes.end())
{