Message186733
Some crazy ideas.
Try something like this:
#define BLOCK unsigned long
if (size >= sizeof(BLOCK)) {
if (*(BLOCK*)data1 != *(BLOCK*)data2)
return 0;
return (memcmp((unsigned char*)data1 + sizeof(BLOCK),
(unsigned char*)data2 + sizeof(BLOCK), size) == 0);
}
if (*(unsigned char*)data1 != *(unsigned char*)data2)
return 0;
return (memcmp(data1, data2, size) == 0);
Or may be unroll memcmp for small size:
switch (size) {
#if SIZEOF_LONG == 8
case 7:
...
#endif
case 3:
...
case 2:
if (((unsigned char*)data1)[1] != ((unsigned char*)data2)[1])
return 0;
case 1:
if (((unsigned char*)data1)[0] != ((unsigned char*)data2)[0])
return 0;
case 0:
return 1;
default:
// case for size >= sizeof(BLOCK)
} |
|
Date |
User |
Action |
Args |
2013-04-13 15:30:12 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, lemburg, pitrou, vstinner, eric.snow |
2013-04-13 15:30:12 | serhiy.storchaka | set | messageid: <1365867012.14.0.972439921641.issue17628@psf.upfronthosting.co.za> |
2013-04-13 15:30:12 | serhiy.storchaka | link | issue17628 messages |
2013-04-13 15:30:11 | serhiy.storchaka | create | |
|