I produced code
for(String buff : Arrays.asList(
FORMULA_PATTERN.matcher(s).group().split("\n")
)
And I started wondering where performance lies with not creating an explicit local container for method returns. (Also, I'm not sure that this works, I'm just prototyping some stuff while waiting for full specs)
Related to Java coding style, local variables vs repeated method calls but I'm curious of the actuality of it.
for the coding pattern (not the specific case, just examples)
Integer.parseInt(buff.substring(buff.length()-1));
Is there any gain/loss over
int x = buff.length() -1;
Integer.parseInt(buff.substring(x);
Or, for the more general case of the language, avoiding primitives
Integer x = buff.length() -1;
Integer.parseInt(buff.substring(x);
This may differ for collections, but my curiosity is the cost associated with Java's pass by value having a cost to instantiate an object to be returned.
Not really concerned with readability, just wondering if, when, and how one method would outperform the other.