On 05/27/2015 12:43 PM, Ivan Gerasimov wrote:


On 27.05.2015 21:08, Xueming Shen wrote:
targLen = max(1, tagLen);   ?

Well, almost :)
With such targLen, (i = j + targLen) would result in i == length() + 1, which 
will cause IOOBE in the following append().

I'm sure the algorithms can be adopted to run correctly with empty target, it 
just needs some accurate checking.

But why can't we consider the first variant of replace()?
http://cr.openjdk.java.net/~igerasim/8058779/02/webrev/

It's still faster and it can handle larger strings without OOME.  I think this 
is important.

I haven't heard any critics of it except for its relative complexity, comparing 
to the original code.
And we have a backup variant with StringBuilder, if problems are found.



Reply via email to