[
https://issues.apache.org/jira/browse/LANG-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13943152#comment-13943152
]
Duncan Jones commented on LANG-990:
-----------------------------------
Patches welcome. It would be interesting to benchmark against the current
implementation to see whether there is a discernible improvement.
> Avoid String allocation in StrBuilder.append(CharSequence)
> ----------------------------------------------------------
>
> Key: LANG-990
> URL: https://issues.apache.org/jira/browse/LANG-990
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.text.*
> Affects Versions: 3.3.1
> Reporter: Mikhail Mazursky
> Fix For: Patch Needed
>
>
> StrBuilder.append(CharSequence) and StrBuilder.append(CharSequence, int, int)
> can be optimized for the case when CharBuffer is passed. Current
> implementation calls toString() method that allocates a new String. In case
> when CharBuffer.hasArray() returns true the buffer-backing char array can be
> accessed directly to copy chars from it.
> Also an instanceOf StrBuilder check can be added to
> StrBuilder.append(CharSequence) and StrBuilder.append(CharSequence, int, int)
> to avoid toString() in that case too (StrBuilder can be passed as
> CharSequence in some cases).
--
This message was sent by Atlassian JIRA
(v6.2#6252)