For clarity I'm only talking about null terminated strings.
I'm familiar with the standard way of doing string comparisons in C with the usage of strcmp. But I feel like it's slow and inefficient.
I'm not necessarily looking for the easiest method but the most efficient.
Can the current comparison method (strcmp) be optimized further while the underlying code remains cross platform?
If strcmp can't be optimized further, what is the fastest way which I could perform the string comparison without strcmp?
Current use case:
- Determine if two arbitrary strings match
- Strings will not exceed 4096 bytes, nor be less than 1 byte in size
- Strings are allocated/deallocated and compared within the same code/library
- Once comparison is complete I do pass the string to another C library which needs the format to be in a standard null terminated format
- System memory limits are not a huge concern, but I will have tens of thousands of such strings queued up for comparison
- Strings may contain high-ascii character set or UTF-8 characters but for my purposes I only need to know if they match, content is not a concern
- Application runs on x86 but should also run on x64
Reference to current strcmp() implementation:
Edit: Clarified the solution does not need to be a modification of strcmp.
Edit 2: Added specific examples for this use case.