Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Back in the days where I used to work in low latency FX trading, we identified this "feature" as we noticed the memory footprint of our process just kept growing and growing but couldn't quite pin down the root cause.

A bit of profiling and then code-digging helped find this oddity. That was probably an optimization where the side effects were not carefully considered. Even the Javadoc is vague (http://docs.oracle.com/javase/6/docs/api/java/lang/String.ht...):

Returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.

Now I see the benefit of the optimization so I am almost against removing it (we coded our own substring at the time). How about Oracle provide a static method to return a substring in 0(1) ?

I believe most Java devs don't even know about the current substring implementation and most programs are not adversely impacted by it either.



> How about Oracle provide a static method to return a substring in 0(1) ?

Not possible anymore, since they used the occasion to eliminate the offset and length fields.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: