You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2019/08/19 19:15:00 UTC

[jira] [Work logged] (LANG-1437) Remove redundant if statements in StringUtils.join

     [ https://issues.apache.org/jira/browse/LANG-1437?focusedWorklogId=297363&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-297363 ]

ASF GitHub Bot logged work on LANG-1437:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Aug/19 19:14
            Start Date: 19/Aug/19 19:14
    Worklog Time Spent: 10m 
      Work Description: coveralls commented on issue #411: LANG-1437: Remove redundant if statements in join methods
URL: https://github.com/apache/commons-lang/pull/411#issuecomment-469427559
 
 
   
   [![Coverage Status](https://coveralls.io/builds/25221082/badge)](https://coveralls.io/builds/25221082)
   
   Coverage increased (+0.0006%) to 95.342% when pulling **ad6e77c0bb4eda0fc701b6931191a141eac62eff on aft90:LANG-1437-redundant-ifs-in-join** into **d5ffc4dde6236ed5afbedfeb333bb87dceb3fe7a on apache:master**.
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 297363)
    Time Spent: 0.5h  (was: 20m)

> Remove redundant if statements in StringUtils.join
> --------------------------------------------------
>
>                 Key: LANG-1437
>                 URL: https://issues.apache.org/jira/browse/LANG-1437
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.6
>            Reporter: Andrei Filip Troie
>            Priority: Minor
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> In the various {{join}} methods in {{StringUtils}}, the for-loop contains an {{if (i > startIndex)}} check (for an example see [here|https://github.com/apache/commons-lang/blob/eb5b11a25c9e61f9b25a540682816ebb103b735c/src/main/java/org/apache/commons/lang3/StringUtils.java#L4203], but it's present in all the {{join}} methods that take an array). 
> That is unnecessary - for the first iteration, we know the condition is false, while for the other iterations, we know the condition is true. So instead, we can do this:
>  * append the first element (at position {{startIndex}})
>  * for every other element (starting at position {{startIndex + 1}}), append the separator, then the element.
> It's basically the same tactic used in the {{Iterable}} version.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)