Original Post
hi, i am writting a proggie that does lots of string compares rapidly... so, i wrote a StrCmp function that is like 5+ times faster than strcmp. im wondering if anyone knows of a even faster way.
this is my method:
i created a templated class that accepts T, a data type like int or double.
i cast my char* to T, and use a T* to step through the string and make comparisons.
it only works if both strings in the compare are CFAST_STRINGS, because the strings need to have their end aligned with sizeof(T), by adding null chars, so that there is not garbage data at the end.
from what i can tell, this is the fastest sort of way.
anyone know of a faster way to compare char*s ? !
thanks
//example of sizeof(int) = 4 array comparisons. char* pc = "joe\0"; //variable as char[4] int* pi = (int*)pc; //variable as int const int* test = (int*)"joe\0"; //constant if ( *pi == *test1) ... //compares sizeof(T) chars at a time. |