Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236048

Cleanup use of Utils.normalizeNewlines

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 20
    • 15
    • tools

      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.

            jjg Jonathan Gibbons
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: