[jira] Created: (LANG-510) Convert StringUtils API to take CharSequence

4 messages Options
Embed this post
Permalink
JIRA jira@apache.org

[jira] Created: (LANG-510) Convert StringUtils API to take CharSequence

Reply Threaded More More options
Print post
Permalink
Convert StringUtils API to take CharSequence
--------------------------------------------

                 Key: LANG-510
                 URL: https://issues.apache.org/jira/browse/LANG-510
             Project: Commons Lang
          Issue Type: Improvement
            Reporter: Henri Yandell
             Fix For: 3.0


Wherever possible, use CharSequence and not String in the StringUtils API.

substring can go to subSequence inside code. The general substring method can be replaced with a subSequence method and substring deprecated(?). One question is whether to implement a CharSequence.indexOf type method. Given that it's merely a walking method(?!?), this might be quite handy and would allow a bunch of StringUtils methods to move over.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

JIRA jira@apache.org

[jira] Commented: (LANG-510) Convert StringUtils API to take CharSequence

Reply Threaded More More options
Print post
Permalink

    [ https://issues.apache.org/jira/browse/LANG-510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752237#action_12752237 ]

Henri Yandell commented on LANG-510:
------------------------------------

Said 'merely' walking method needs to match JVM speed though before we'd want the rest of the codebase to be dependent on it. Which I doubt we'd want to do.

Here is the Harmony String.java implementation:

http://svn.apache.org/repos/asf/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java

It uses both direct private variable access on the subString and it works at the array level without having to incur charAt method calls.

Various naive implementations of unoptimized that I just hacked together only reach the 3x speed (and no idea if they're actually accurate).  So I think that's it for the idea of moving the parts of StringUtils that rely on indexOf over to CharSequence.

> Convert StringUtils API to take CharSequence
> --------------------------------------------
>
>                 Key: LANG-510
>                 URL: https://issues.apache.org/jira/browse/LANG-510
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>
> Wherever possible, use CharSequence and not String in the StringUtils API.
> substring can go to subSequence inside code. The general substring method can be replaced with a subSequence method and substring deprecated(?). One question is whether to implement a CharSequence.indexOf type method. Given that it's merely a walking method(?!?), this might be quite handy and would allow a bunch of StringUtils methods to move over.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

JIRA jira@apache.org

[jira] Commented: (LANG-510) Convert StringUtils API to take CharSequence

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/LANG-510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752238#action_12752238 ]

Henri Yandell commented on LANG-510:
------------------------------------

Though...

Could have an indexOf method for CharSequence that IF both string and substring are String, then it casts to String. That has a pretty minimal cost. Equally could add optimized code for StrBuilder and StringBuffer too.

That's tempting.

> Convert StringUtils API to take CharSequence
> --------------------------------------------
>
>                 Key: LANG-510
>                 URL: https://issues.apache.org/jira/browse/LANG-510
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>
> Wherever possible, use CharSequence and not String in the StringUtils API.
> substring can go to subSequence inside code. The general substring method can be replaced with a subSequence method and substring deprecated(?). One question is whether to implement a CharSequence.indexOf type method. Given that it's merely a walking method(?!?), this might be quite handy and would allow a bunch of StringUtils methods to move over.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

JIRA jira@apache.org

[jira] Commented: (LANG-510) Convert StringUtils API to take CharSequence

Reply Threaded More More options
Print post
Permalink
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/LANG-510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752241#action_12752241 ]

Henri Yandell commented on LANG-510:
------------------------------------

Other notes:

1) Underlying String/StrBuilder/StringBuffer indexOf methods all take String as the delimiter. So it would be very tempting to generate a String internally on the delimiter.
2) Boyer Moore implementation might be a useful feature in text.* or in Codec.

> Convert StringUtils API to take CharSequence
> --------------------------------------------
>
>                 Key: LANG-510
>                 URL: https://issues.apache.org/jira/browse/LANG-510
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>
> Wherever possible, use CharSequence and not String in the StringUtils API.
> substring can go to subSequence inside code. The general substring method can be replaced with a subSequence method and substring deprecated(?). One question is whether to implement a CharSequence.indexOf type method. Given that it's merely a walking method(?!?), this might be quite handy and would allow a bunch of StringUtils methods to move over.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.