Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4244

[perf] Use StringBuilder rather than calling write many times to increase performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Invalid
    • 2.2.12, 2.3.1
    • None
    • None
    • None

    Description

      Using StringBuilder.append performs better than calling Writer.write multiple times because the path length for a StringBuffer.append is less than the path length of a Writer.write operation. By using StringBuilder, you only have to call the write method once instead of N number of times per method.

      The Shared StringBuilder may have some issues as well if there is any multi-threaded use of the Shared StringBuilder. If multiple threads could use a particular StringBuilder you would end up getting incorrect output. Another issue with the Shared StringBuilder for performance is it requires a call to get it which can be more expensive than just newing up a new StringBuilder.

      From looking at the myfaces code, the Shared StringBuilder is used only for special cases presently and not widely used.

      Attachments

        Issue Links

          Activity

            People

              paul.nicolucci Paul Nicolucci
              paul.nicolucci Paul Nicolucci
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: