![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
frs
I would like to turn the code as efficient as possible to improve sampling times.
So you have this in mind?
Code:
switch (dev_type)
{
case 1:
while (!poll_interrupt)
{
/* fetch data from dev1 */
/* translate information */
/* send it somewhere */
}
break;
case 2:
while (!poll_interrupt)
{
/* fetch data from dev2 */
/* translate information */
/* send it somewhere */
}
break;
}
But you are concerned about the code duplication?
Personally, I would recommend that you test. Does any attempted optimisation really make a tangible difference to begin with, after compiler optimisations have been applied?
![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
frs
The dev_type is an input parameter, but it doesn't change during runtime.
As in it is actually a macro?