The optimised aligned version was broken and not used.

As pointed out by Hamish the alignment used && in second case
instead of &, which meant it was never used.

Another error when a32 was 0xFF000000 and b32 was 0xFF00FFFF
would return a non zero value. A simple fix for the issues
with going over to the byte by byte comparison failed, so
rather than leave broken code I remove this for the time being.

Not the best code I've written obviously.
This commit is contained in:
Fredrik Holmqvist
2013-03-15 11:49:13 +01:00
parent 3881911cce
commit 39a81e5ac6
-13
View File
@@ -15,19 +15,6 @@
int
strcmp(char const *a, char const *b)
{
/* Make sure we don't pass page boundries on a or b when doing four byte
comparisons */
if ((((addr_t)a) & 3) == 0 && (((addr_t)b) && 3) == 0) {
uint32* a32 = (uint32*)a;
uint32* b32 = (uint32*)b;
while (LACKS_ZERO_BYTE(*a32)) {
int32 cmp = *a32++ - *b32++;
if (cmp != 0)
return cmp;
}
return *a32 - *b32;
}
while (true) {
int cmp = (unsigned char)*a - (unsigned char)*b++;
if (cmp != 0 || *a++ == '\0')