Wish list for IDEA 6 :-)

How about an inspection/intention that can transform

with

A requirement is, of course, that foo is invariant.

/Mikael

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

Dave Griffith wrote:

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


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

0
Avatar
Permanently deleted user

An inspection would certainly have to be. An intention could offer it irrespective of safety.

--Dave Griffith

0
Avatar
Permanently deleted user

Mikael Karlsson schrieb:

How about an inspection/intention that can transform

    if (foo) {
>       doX(i);
>    } else {
>       doY(i);
>    }
> }]]>

with

    for (int i = 0; i < 10; i++) {
>       doX(i);
>    }
> } else {
>    for (int i = 0; i < 10; i++) {
>       doY(i);
>    }
> }]]>

A requirement is, of course, that foo is invariant.

/Mikael


Isn't the "improved" version much more redundant? Unless foo is an
expensive method call, I see no reason to extract the test.

0
Avatar
Permanently deleted user

Michael Riess wrote:

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!"

0

请先登录再写评论。