From time to time I see code like this:
if (id.split(":").length > 1) {
sub_id = id.split(":")[1];
parent_id = id.split(":")[0];
}
Wouldn't it be better (and faster) to do something like
String [] ids = id.split(":");
if (ids.length > 1) {
sub_id = ids[1];
parent_id = ids[0];
}
This way you don't have to call 'split()' multiple times, or will the compiler/JIT do such optimizations?
indexOfto find the ':' and twosubstringcalls to extract each part of the id ought to be much faster than both alternatives.