1) The String.substring() in 1.4 kept original char[] reference in the
new String, which was of course not good. In 1.8+ it always copies the
portion of char array.
So all constructs can be safely changed:
new String(s.substring(x)) -> s.substring(x)
new String(s.substring(x,y)) -> s.substring(x,y)
2) String(String) in 1.4 copied the original char array if the size was
different, so by new String(String) one tried to avoid memory leaks. In
1.8+ new String(String) simply reuses the original pointers, so no gain
here and we create new (wasted) String reference.
So except few places where a *different* String *pointer* is required,
all constructs can be safely changed:
new String(string) -> string
new String(stringBuffer.toString()) -> stringBuffer.toString()
Change-Id: I061d1a82185605d0fba16a8885752d5da948ed20
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>