String.equalsIgnoreCase(...) optimization

Andrew Haley aph at
Tue Apr 26 15:18:49 UTC 2016

On 04/26/2016 03:25 PM, Andrey wrote:
> May be can create optimized regionMatches(...) for use in equalsIgnoreCase(...)?

When the HotSpot JVM's just-in-time compiler optimizes this code it
inlines all of these tests, realizes that they are constant values,
and generates no code for them.  All the generated code does is check
that the strings have the same coder and are the same length, then it
goes into an unrolled loop checking that the characters are the same.
If they're different then we have to do some more testing.

If you want to optimize any library code its a great idea to make some
changes and use JMH (
to see if your change makes your test run faster.


More information about the core-libs-dev mailing list