Skip to main content
added 93 characters in body
Source Link
Tim Schmelter
  • 461.8k
  • 79
  • 718
  • 980

You should measure it to see whether it's worth to optimize or not(I'm very sure that it's not). Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}

All "ways" seem to be releated, otherwise they wouldn't appear in the same switch. Hence it makes sense to bundle them in one method first which does the switch.

You should measure it to see whether it's worth to optimize or not. Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}

All "ways" seem to be releated, otherwise they wouldn't appear in the same switch. Hence it makes sense to bundle them in one method first which does the switch.

You should measure it to see whether it's worth to optimize or not(I'm very sure that it's not). Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}

All "ways" seem to be releated, otherwise they wouldn't appear in the same switch. Hence it makes sense to bundle them in one method first which does the switch.

added 87 characters in body; added 80 characters in body
Source Link
Tim Schmelter
  • 461.8k
  • 79
  • 718
  • 980

You should measure it to see whether it's worth to optimize or not. Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}

All "ways" seem to be releated, otherwise they wouldn't appear in the same switch. Hence it makes sense to bundle them in one method first which does the switch.

You should measure it to see whether it's worth to optimize or not. Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}

You should measure it to see whether it's worth to optimize or not. Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}

All "ways" seem to be releated, otherwise they wouldn't appear in the same switch. Hence it makes sense to bundle them in one method first which does the switch.

Source Link
Tim Schmelter
  • 461.8k
  • 79
  • 718
  • 980

You should measure it to see whether it's worth to optimize or not. Personally i prefer the first for readability and conciseness(less code, less prone to errors, more "dry").

Here's another approach which is even more concise:

for(int i = 0; i < count; i++)
{
    doAllWays(way, i); // let the method decide what to do next
}