-
Enhancement
-
Resolution: Fixed
-
P3
-
15
-
b12
Utils.normalizeNewlines is used to ensure that we always only use standard \n newlines in the generated files, whatever the style of newlines \n \r\n \r may be found in user input (doc comments or command-line options.
But, it unconditionally copies the argument string first into a StringBuilder and then into the final result string. And, on some code paths in commentTagsToContent, it may be called multiple times on the same underlying data.
All user-provided content ends up in either RawHtml or StringContent nodes, and so a better solution is to defer checking for non-standard newlines until the string is actually written out.
Note that when writing StringContent, we are already scanning the individual characters for < > & characters that need to be written as entities.
At a minimum, we could move the normalization into RawHtml or StringContent, to do it (if necessary) when building those nodes.
But, it unconditionally copies the argument string first into a StringBuilder and then into the final result string. And, on some code paths in commentTagsToContent, it may be called multiple times on the same underlying data.
All user-provided content ends up in either RawHtml or StringContent nodes, and so a better solution is to defer checking for non-standard newlines until the string is actually written out.
Note that when writing StringContent, we are already scanning the individual characters for < > & characters that need to be written as entities.
At a minimum, we could move the normalization into RawHtml or StringContent, to do it (if necessary) when building those nodes.