You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by Jason Dillon <ja...@planet57.com> on 2010/05/30 08:55:52 UTC

Use of String.valueOf() and String.format("... %s", ...) is pointless

I've found a few places, that I happened to bump into while debugging, that do stuff like:

<snip>
        throw new IllegalArgumentException(String
            .format("Cannot create default factory for class: %s", String.valueOf(clazz)));
</snip>

This is complexly pointless use of String.valueOf(), as this is exactly what the "%s" token will do.  So its just wasting a method call, inflating the byte-code and cluttering up the source.

--jason

Re: Use of String.valueOf() and String.format("... %s", ...) is pointless

Posted by Bryant Luk <br...@gmail.com>.
I did a general search and made the changes where I saw this pattern.
If you see any additional ones, then please feel free to submit a
patch.  Thanks.

On Sun, May 30, 2010 at 1:55 AM, Jason Dillon <ja...@planet57.com> wrote:
> I've found a few places, that I happened to bump into while debugging, that do stuff like:
>
> <snip>
>        throw new IllegalArgumentException(String
>            .format("Cannot create default factory for class: %s", String.valueOf(clazz)));
> </snip>
>
> This is complexly pointless use of String.valueOf(), as this is exactly what the "%s" token will do.  So its just wasting a method call, inflating the byte-code and cluttering up the source.
>
> --jason