ScriptEngineFactory.getProgram uses suboptimal alogorithm

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 17
    • Component/s: core-libs
    • None

      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.

            Assignee:
            Sundararajan Athijegannathan
            Reporter:
            Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: