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

Cleanup use of Utils.normalizeNewlines

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: New
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 15
    • Fix Version/s: None
    • Component/s: tools
    • Labels:

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            jjg Jonathan Gibbons
            Reporter:
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: