Что-то уже совсем голова не варит. Помогите, пожалуйста, с оптимизацией следующего кода:
void EnableBillTypes(std::list<unsigned int> billTypes)
{
unsigned char cmd[7] = {CMD_ENABLEBILLTYPES, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
std::list<unsigned int>::iterator it;
for ( it=billTypes.begin() ; it != billTypes.end(); it++ )
{
unsigned char tmp[1] = {0x00};
switch(*it)
{
case 23:
case 15:
case 7:
tmp[0] = 0x80;
break;
case 22:
case 14:
case 6:
tmp[0] = 0x40;
break;
case 21:
case 13:
case 5:
tmp[0] = 0x20;
break;
case 20:
case 12:
case 4:
tmp[0] = 0x10;
break;
case 19:
case 11:
case 3:
tmp[0] = 0x08;
break;
case 18:
case 10:
case 2:
tmp[0] = 0x04;
break;
case 17:
case 9:
case 1:
tmp[0] = 0x02;
break;
case 16:
case 8:
case 0:
tmp[0] = 0x01;
break;
}
if(*it >= 0 && *it <= 7)
{
cmd[3] = cmd[3] + tmp[0];
}
else if(*it > 7 && *it <= 15)
{
cmd[2] = cmd[2] + tmp[0];
}
else if(*it > 15 && *it <= 23)
{
cmd[1] = cmd[1] + tmp[0];
}
else
{
printf("Unknown bill type");
return;
}
}
printf("Send command ENABLE BILL TYPES\n");
Request(cmd, sizeof(cmd));
}