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 2022/04/03 14:21:00 UTC

[jira] [Work logged] (LANG-1679) StringUtils.unwrap() may be implemented faster

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

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

                Author: ASF GitHub Bot
            Created on: 03/Apr/22 14:20
            Start Date: 03/Apr/22 14:20
    Worklog Time Spent: 10m 
      Work Description: garydgregory merged pull request #844:
URL: https://github.com/apache/commons-lang/pull/844


   


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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

    Worklog Id:     (was: 752051)
    Time Spent: 20m  (was: 10m)

> StringUtils.unwrap() may be implemented faster
> ----------------------------------------------
>
>                 Key: LANG-1679
>                 URL: https://issues.apache.org/jira/browse/LANG-1679
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: clover
>            Priority: Minor
>             Fix For: 3.13.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> public static String unwrap(final String str, final String wrapToken) {
>         if (isEmpty(str) || isEmpty(wrapToken) || str.length() < 2 * wrapToken.length())
> {             return str;         }
>         if (startsWith(str, wrapToken) && endsWith(str, wrapToken)) {
>            {color:#de350b} // When we come here, startIndex must be 0. Thus, startIndex is redundant.{color}
>             final int startIndex = str.indexOf(wrapToken);
> {color:#ff0000}            final int endIndex = str.lastIndexOf(wrapToken);{color}
>             final int wrapLength = wrapToken.length();
> {color:#172b4d}           {color:#de350b}// (startIndex != -1 && endIndex != -1) is always true{color}{color}
> {color:#ff0000}            if (startIndex != -1 && endIndex != -1) {{color}
> {color:#ff0000}                return str.substring(startIndex + wrapLength, endIndex);{color}
> {color:#ff0000}            }{color}
>         }
>         return str;
>     }
>  
> *As commented above, unwrap() could be improved:*
> public static String unwrap(final String str, final String wrapToken) {
>         if (isEmpty(str) || isEmpty(wrapToken) || str.length() < 2 * wrapToken.length()) \{             return str;         }
>         if (startsWith(str, wrapToken) && endsWith(str, wrapToken)) {
> {color:#ff0000}                return str.substring(wrapToken.length(), str.lastIndexOf(wrapToken));{color}
> {color:#ff0000}            }{color}
>         }
>         return str;
>     }



--
This message was sent by Atlassian Jira
(v8.20.1#820001)