I need to check the string to see it matches any of the prefixes. The number of prefixes to be compared will increase in the future. So I have concern on the performance of code like below. What are the options to make it run faster when there are lots of strings need to be checked?
int checkString(const char *name)
{
if(!name) return 0;
if(strncmp(name, "AE_", 3) == 0 ) return 1;
if(strncmp(name, "AEDZ_", 5) == 0 ) return 1;
if(strncmp(name, "EDPZ_", 5) == 0 ) return 1;
if(strncmp(name, "EFAN_", 5) == 0 ) return 1;
if(strncmp(name, "E_GCA", 5 ) == 0 ) return 1;
if(strncmp(name, "EFFAN_", 6) == 0 ) return 1;
if(strncmp(name, "EPDPZ_", 6) == 0 ) return 1;
if(strncmp(name, "EDDPZ_", 6) == 0 ) return 1;
if(strncmp(name, "ECADF_", 6) == 0 ) return 1;
if(strncmp(name, "EPCEA_", 6) == 0 ) return 1;
if(strncmp(name, "CFEXXX_", 7) == 0 ) return 1;
if(strncmp(name, "IFEXX_", 7) == 0 ) return 1;
if(strncmp(name, "EINFFAN_", 8) == 0 ) return 1;
if(strncmp(name, "NXXEFAN_", 8) == 0 ) return 1;
if(strncmp(name, "ENAEAZY_", 8) == 0 ) return 1;
if(strncmp(name, "EYYYYYY_", 8) == 0 ) return 1;
if(strncmp(name, "ENEOENUE_", 9) == 0 ) return 1;
/*
more strncmp to be added.
*/
return 0;
}