desktop wrote:
> Are there any performance issues between:
>
> bool run = true;
> while(run) {
>
> if (bob1 &&){
>
> //dothing
> break;
> }
>
>
> if(bob2) {
>
> //dothing
> break;
> }
>
>
>
> if(bob2) {
This is unreachable. You already have 'bob2' above. I assume
you meant 'bob3'.
>
> //dothing
> break;
> }
>
> run = false;
>
> }
>
> (I am aware that a switch could be used. But sometimes the conditions
> consists of more parts and therefore a switch might not apply)
>
>
> With nested ifs:
>
>
> if (bob1){
>
> //dothing
> break;
'break' outside of any loop is a syntax error.
> } else {
>
>
> if(bob2) {
>
> //dothing
> break;
> } else {
> if(bob2) {
>
> //dothing
> break;
> }
> }}
>
>
> I prefer the while version event though it might be a bit unorthodox.
I don't believe that "issues" can be "between". I think "issues"
can be "with" or sometimes "in". In the code you posted, however,
I see a simple issue: the former does not convey the intent. If
you intended to have a branching processing, do it. Why wrap it
into an artificial logic structure? And there is no need to nest
anything, just chain them (which is basically the same as nesting
only without curly braces):
if (bob1) {
do one
}
else if (bob2) {
do two
}
else fi (bob3) {
do three
}
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask