Isn't the "improved" version much more redundant? Unless foo is an expensive method call, I see no reason to extract the test.
There are several possible reasons. E.g. it could be in preparation for refactoring such as Extract Method on each loop, it could be to optimize the looping, or in preparation for an optimization like loop unrolling or whatever.
-- Rob Harwood Software Developer JetBrains Inc. http://www.jetbrains.com "Develop with pleasure!"
Good one. Please submit a JIRA request. Call it "Move test out of loop", and mention that it could be either an intention or inspection.
--Dave Griffith
Dave Griffith wrote:
This inspection / intention will have to be smart enough to understand
that the condition is not related to anything that happens in the loop.
For example, if the condition is "if (items+ == 0)" it is not possible
to extract it.
Amnon
An inspection would certainly have to be. An intention could offer it irrespective of safety.
--Dave Griffith
Mikael Karlsson schrieb:
Isn't the "improved" version much more redundant? Unless foo is an
expensive method call, I see no reason to extract the test.
Michael Riess wrote:
There are several possible reasons. E.g. it could be in preparation for
refactoring such as Extract Method on each loop, it could be to optimize
the looping, or in preparation for an optimization like loop unrolling
or whatever.
--
Rob Harwood
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Here's the JIRA item.
http://www.jetbrains.net/jira/browse/IDEABKL-3385