|
Re: the comparisons of if clauses are still executed completely
[Re: jcl]
#328606
06/14/10 09:37
06/14/10 09:37
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
But in some cases the code can't be replaced by just using "if" instead of "&&":
ENTITY* ent = NULL;
if(ent != NULL) {
if (is(ent, FLAG1)) {
... do something ...
} else {
... do something else ...
}
} else {
... do something else (the same else as above) ...
}
For this code I need either code duplication or I have to set a boolean and check this to decide which code has to be executed. But it could be like this:
ENTITY* ent = NULL;
if(ent != NULL && is(ent, FLAG1)) {
... do something ...
} else {
... do something else ...
}
So it makes the code worse and longer. Regards, Pegamode.
|
|
|
Re: the comparisons of if clauses are still executed completely
[Re: jcl]
#328615
06/14/10 10:19
06/14/10 10:19
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
|
|
|
Re: the comparisons of if clauses are still executed completely
[Re: Superku]
#360385
02/23/11 20:15
02/23/11 20:15
|
Joined: Sep 2003
Posts: 9,859
FBL
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 9,859
|
|
|
|
|