diff options
author | Alexander Neundorf <neundorf@kde.org> | 2008-02-17 17:31:29 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2008-02-17 17:31:29 (GMT) |
commit | e13db53a9aee6064caeee62b1833f84d006a3439 (patch) | |
tree | 7675a1f64dae274bc71e404c66e78fb6dbcada78 | |
parent | 21f4cd7c8bccbb810ab41f6c42ebb83297b0b8d9 (diff) | |
download | CMake-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.cxx | 13 |
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['<'] = "<"; - escapes['>'] = ">"; - escapes['&'] = "&"; - escapes['\n'] = "<br>"; + static std::map<char,std::string> escapes; + if (escapes.empty()) + { + escapes['<'] = "<"; + escapes['>'] = ">"; + escapes['&'] = "&"; + escapes['\n'] = "<br>"; + } if (escapes.find(c) == escapes.end()) { |