ultimatepp/uppdev/Compare/QC.cpp
cxl 4a1c627474 Adding uppdev....
git-svn-id: svn://ultimatepp.org/upp/trunk@328 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2008-08-15 08:36:24 +00:00

21 lines
500 B
C++

#include <Core/Core.h>
using namespace Upp;
int MemCmp_aligned__(const char *a, const char *b, size_t len)
{
const dword *x = (dword *)a;
const dword *y = (dword *)b;
const dword *e = x + (len >> 2);
while(x < e) {
if(*x != *y)
return SwapEndian32(*x) < SwapEndian32(*y) ? -1 : 1;
x++;
y++;
}
len &= 3;
if(len == 0) return 0;
len <<= 3;
dword mask = 0xffffffff << (len << 3);
return (SwapEndian32(*x) >> mask) < (SwapEndian32(*y & mask) >> mask) ? -1 : 1;
}