commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <>
Subject [jira] [Closed] (LANG-770) StringUtils.join(Object[]) performance issue if .toString() is not trivial
Date Mon, 04 Jun 2012 07:44:24 GMT


Henri Yandell closed LANG-770.

    Resolution: Not A Problem

Agreed. Resolving this as Not A Problem.
> StringUtils.join(Object[]) performance issue if .toString() is not trivial
> --------------------------------------------------------------------------
>                 Key: LANG-770
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Joe Barnett
> I have some code that builds syntax trees, and then uses a combination of TreeNode.toString()
and StringUtils.join() to recursively convert that syntax tree to a String representation.
> example .toString() of a SumNode class, where children is a TreeNode[]:
> public String toString() {
>     return StringUtils.join(children, "+");
> }
> The problem is, StringUtils.join(Object[], String, int, int) is trying to be too smart
about preallocating the StringBuffer size it uses internally, as it does:
> bufSize *= ((array[startIndex] == null ? 16 : array[startIndex].toString().length())
>                         + separator.length());
> followed by implicitly calling .toString() on each object in the array:
> buf.append(array[i]);
> For deep syntax trees, this results in incredibly bad performance, as when traversing
the syntax tree, every time we go to the first node, we re-expand the entire tree below that
node (which does the same thing with the first node below that, etc).

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message