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

ScriptEngineFactory.getProgram uses suboptimal alogorithm

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • None
    • 17
    • core-libs
    • None

    Description

      The code example in ScriptEngineFactory.getProgram uses string concatenation is a subopotimal way:

       public String getProgram(String... statements) {
            String retval = "<?\n";
            int len = statements.length;
            for (int i = 0; i < len; i++) {
                retval += statements[i] + ";\n";
            }
            return retval += "?>";
       }

      A StringJoiner would yield concise code and likely be more efficient too.

      Attachments

        Activity

          People

            sundar Sundararajan Athijegannathan
            darcy Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: