|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by atomicgs12 in Algorithms, C Programming Language, C++ Programming Language
I have some code that does a while loop checking a number of values via a function. What I am looking for is a more processor efficient way to reduce the amount of code lines and to speed up the loop, machine wise, as much as possible. I was thinking of something either using a list or some kind of bitwise, and/or ing/sifting thing. The pseudo code for the loop is something like:
int arrSuccess[50]={0};
int arrStuff[50] = {0};
int PassFail=0;
int nVal1 = 18;
int nVal2 = 23;
int nVal3 = 112;
.
.
.
int nVal50 = 786;
while(PassFail == 0)
{
if(arrSuccess[0] != 1)
{
// if DoSomething is successful it will return a 1, failure = 0
arrSuccess[0] = DoSomething(arrStuff[nVal1
]);
}
.
.
.
if(arrSuccess[49] != 1)
{
arrSuccess[0] = DoSomething(arrStuff[nVal5
0]);
}
PassFail = 1;
for(int 1 = 0; i<50; i++)
{
if(arrSuccess[i] == 0)
{
PassFail = 0;
break;
}
}
}
So I would like to eliminate the multiple lines for the call to the DoSomething function.
Thanks
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625