Inefficient code of String.indexOf(String)

David Chase david.r.chase at oracle.com
Mon Jun 17 17:15:38 UTC 2013


For sufficiently large strings, indexOf can also be profitably parallelized.

David

On 2013-06-17, at 2:14 AM, Martin Buchholz <martinrb at google.com> wrote:

> You are not the first person to have this idea.
> It is unlikely that you will succeed in changing the algorithm, because the
> jit-optimized brute-force algorithm is "almost always" faster.
> But go ahead and prove me wrong!
> 
> 
> On Sun, Jun 16, 2013 at 3:53 AM, Anubhav Chaturvedi <
> mailforanubhav at gmail.com> wrote:
> 
>> Hello,
>> 
>> I have recently started to explore the source code and am new to the open
>> source community. I observed that in String.class within java.lang , the
>> indexOf method, line 1715, uses the bruteforce approach when it comes to
>> string matching. This method is used by the contains(CharSequence) method.
>> There are a number of algorithms that can perform the task more
>> efficiently.
>> 
>> I would like to bring the required changes and needed your advice on this.




More information about the core-libs-dev mailing list