[
https://issues.apache.org/jira/browse/LANG-1675?focusedWorklogId=684230&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-684230
]
ASF GitHub Bot logged work on LANG-1675:
----------------------------------------
Author: ASF GitHub Bot
Created on: 20/Nov/21 15:34
Start Date: 20/Nov/21 15:34
Worklog Time Spent: 10m
Work Description: garydgregory commented on pull request #812:
URL: https://github.com/apache/commons-lang/pull/812#issuecomment-974667083
Thanks for the update @kinow
This pattern does not make sense to me:
```
return stringBuilder
.deleteCharAt(stringBuilder.length() - 1)
.toString();
```
First `deleteCharAt` is called which calls `System.arraycopy`, then
`toString()` is called which allocates the new String.
Why not skip the first part by simply saying:
```
return stringBuilder.substring(0, stringBuilder.length() - 1);
```
?
Also for the char and boolean versions, it seems like the builder size can
be simply computed because each element's String version is a fixed size
(assuming 5 for boolean). For ints and longs it might not be worth it as you'd
have to assume the max size.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 684230)
Time Spent: 4h 20m (was: 4h 10m)
> Improve performance of StringUtils.join for primitives.
> -------------------------------------------------------
>
> Key: LANG-1675
> URL: https://issues.apache.org/jira/browse/LANG-1675
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: Hubert Wojciechowski
> Priority: Minor
> Time Spent: 4h 20m
> Remaining Estimate: 0h
>
> This is [~XenoAmess] comment from PR:
> [https://github.com/apache/commons-lang/pull/784]
> {noformat}
> Please look at the sources in JDK, where
> java.lang.AbstractStringBuilder#append(boolean b)
> In short, for basic types, should not convert them to String, but use
> StringBuilder directly, will bring far better performance.
> BUT I just foundout that you did not bring this issue, this issue is already
> in commons-lang before your pr.
> So I will not stop you from merging this in, but still I will find time to
> refactor the whole join serial functions later.
> {noformat}
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)