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
This commit is contained in:
Alexander Neundorf 2008-02-17 12:31:29 -05:00
parent 21f4cd7c8b
commit e13db53a9a
1 changed files with 8 additions and 5 deletions

View File

@ -32,11 +32,14 @@ static bool cmDocumentationIsHyperlinkChar(char c)
static void cmDocumentationPrintHTMLChar(std::ostream& os, char c) static void cmDocumentationPrintHTMLChar(std::ostream& os, char c)
{ {
// Use an escape sequence if necessary. // Use an escape sequence if necessary.
std::map<char,std::string> escapes; static std::map<char,std::string> escapes;
escapes['<'] = "&lt;"; if (escapes.empty())
escapes['>'] = "&gt;"; {
escapes['&'] = "&amp;"; escapes['<'] = "&lt;";
escapes['\n'] = "<br>"; escapes['>'] = "&gt;";
escapes['&'] = "&amp;";
escapes['\n'] = "<br>";
}
if (escapes.find(c) == escapes.end()) if (escapes.find(c) == escapes.end())
{ {