1
0
Эх сурвалжийг харах

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

Alexander Neundorf 18 жил өмнө
parent
commit
e13db53a9a

+ 8 - 5
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())
     {