From e13db53a9aee6064caeee62b1833f84d006a3439 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sun, 17 Feb 2008 12:31:29 -0500 Subject: [PATCH] PERF: reduce time for full docs as HTML from 1.4 s to 0.2 s, the map is now created and filled only once instead for every character I guess a simple case-switch would be still faster. Alex --- Source/cmDocumentationFormatterHTML.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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()) {