Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround for the changed jdk6 to jdk7 behavior of substring

Up to jdk7u6 the substring method was lightning fast because it simply used pointers within an existing string - thus required no memory copying. I used that feature extensively in implementing parsers.

Given the length of time since that critical performance feature was removed there must be some well oiled replacement.

Note: I could theoretically go back and copy the implementation from jdk6. But IIRC it was wrapped up pretty heavily in the entire String class - i.e. not easily extracted.

So is such an implementation lying around - e.g in one of the high performance jvm parser libraries?

like image 907
WestCoastProjects Avatar asked Nov 10 '15 00:11

WestCoastProjects


1 Answers

You might be able to do what you need with CharBuffer, which implements the CharSequence interface. See, in particular, CharBuffer.subSequence.

like image 126
GreyBeardedGeek Avatar answered Nov 06 '22 06:11

GreyBeardedGeek