Add getChars to CharSequence

Martin Buchholz martinrb at google.com
Thu Apr 11 21:12:52 UTC 2013


On Thu, Apr 11, 2013 at 12:55 PM, Ulf Zibis <Ulf.Zibis at cosoco.de> wrote:

>
> Anyway as those methods all need some CPU time to execute normally, I'm
> not sure if it's worth to save 1 comparison by outsourcing.
>

Saving one comparison is worth doing in any case in these
performance-critical methods.
"Out-lining" the creation of the detail message is a standard refactoring
that is known to make hotspot happy.


> Additionally having getCharsOutOfBounds as source for the exceptions
> cause/stacktrace could lead to some confusion.
>

Let's use this sane exception detail:

    private String outOfBoundsMsg(int srcBegin, int srcEnd) {
        return "srcBegin = " + srcBegin
            + ", srcEnd = " + srcEnd
            + ", length() = " + count;
    }



More information about the core-libs-dev mailing list