summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2008-02-17 17:31:29 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2008-02-17 17:31:29 (GMT)
commite13db53a9aee6064caeee62b1833f84d006a3439 (patch)
tree7675a1f64dae274bc71e404c66e78fb6dbcada78
parent21f4cd7c8bccbb810ab41f6c42ebb83297b0b8d9 (diff)
downloadCMake-e13db53a9aee6064caeee62b1833f84d006a3439.zip
CMake-e13db53a9aee6064caeee62b1833f84d006a3439.tar.gz
CMake-e13db53a9aee6064caeee62b1833f84d006a3439.tar.bz2
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
-rw-r--r--Source/cmDocumentationFormatterHTML.cxx13
1 files changed, 8 insertions, 5 deletions
diff --git a/Source/cmDocumentationFormatterHTML.cxx b/Source/cmDocumentationFormatterHTML.cxx
index 175bc8d..7422ef4 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<char,std::string> escapes;
- escapes['<'] = "&lt;";
- escapes['>'] = "&gt;";
- escapes['&'] = "&amp;";
- escapes['\n'] = "<br>";
+ static std::map<char,std::string> escapes;
+ if (escapes.empty())
+ {
+ escapes['<'] = "&lt;";
+ escapes['>'] = "&gt;";
+ escapes['&'] = "&amp;";
+ escapes['\n'] = "<br>";
+ }
if (escapes.find(c) == escapes.end())
{