Janino

Suboptimal compilation strategy for the string concatenation operator.

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Any
  • Number of attachments :
    0

Description

Janino currently uses repeated calls to the String.concat() method to implement the concatenation of strings using the + operator. While this is certainly optimal in the case of two operands, larger numbers of operands result in degraded performance (due to the resulting quadratic complexity). Though Janino performs a 'constant folding' optimization that resolves this in many/most instances, the performance of non-constant concatenation is still a problem.

A test case can be dowloaded from:
http://www.tomgibara.com/janino-evaluation

A preliminary benchmark comparing the performance of concat() to StringBuffers and StringBuilders in Java 1.5 and Java 6 might be useful and is available at:
http://www.tomgibara.com/janino-evaluation/string-concatenation-benchmark

Note this behaviour has been observed in Janino versions 2.5.1 - 2.5.3 inclusive, but is probably present in all versions.

Activity

Hide
Arno Unkrig added a comment -

Fixed in 2.5.5.

Show
Arno Unkrig added a comment - Fixed in 2.5.5.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: