I have a piece of code that basically looks like this. The problem is that I run this code 10 thousand times and need to optimize it. Any suggestions are welcome.
int[] someArray = { 1, 631, 632, 800, 801, 1600, 1601, 2211, 2212, 2601, 2602 };
id = 806
for (int i = 0; i < someArrayLenght; i++)
{
if (someArray[i] <= id)
return i;
}
Edit: Sorry the condition was incorrect. It should return an identifier when 806 is greater than 801. I hope you can make sense from it.
source
share