On Sat, Jan 26, 2008 at 10:51:18PM -0800, Linus Torvalds wrote:Let's rename do_folding as something else, because it is not a real folding, but a preparation step for hash calculation. Keeping these steps separately simplifies the code, and allows further optimization, for instance, you do not need this do_folding step on a case-sensitive filesystem. Though it is certainly possible to mix both steps together, it bloats the code and makes it less readable. Of course, the idea to avoid a temporary buffer and do everything at once is very appealing, so I gave it a try -- and here is a 32-bit version of name_hash(), but I am not very happy with the result: #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) #define mix(a,b,c) \ { \ a -= c; a ^= rot(c, 4); c += b; \ b -= a; b ^= rot(a, 6); a += c; \ c -= b; c ^= rot(b, 8); b += a; \ a -= c; a ^= rot(c,16); c += b; \ b -= a; b ^= rot(a,19); a += c; \ c -= b; c ^= rot(b, 4); b += a; \ } #define final(a,b,c) \ { \ c ^= b; c -= rot(b,14); \ a ^= c; a -= rot(c,11); \ b ^= a; b -= rot(a,25); \ c ^= b; c -= rot(b,16); \ a ^= c; a -= rot(c,4); \ b ^= a; b -= rot(a,14); \ c ^= b; c -= rot(b,24); \ } #define hash_value(x) \ hs[hp] += (x); \ if (++hp == 3) { \ mix (hs[0], hs[1], hs[2]); \ hp = 0; \ } unsigned int name_hash(const char *name, unsigned size) { unsigned hp = 0; unsigned hs[3]; hs[0] = hs[1] = hs[2] = 0xdeadbeef + size; do { unsigned char c; if (size >= sizeof(unsigned)) { unsigned val = get_unaligned_uint(name); if (!(val & 0x80808080)) { val &= ~0x20202020; hash_value(val); name += sizeof(val); size -= sizeof(val); continue; } } while (!((c = *name) & 0x80)) { hash_value(c & ~0x20); name++; if (!--size) goto done: } do { // TODO: add denormalization for Mac unsigned val = towupper (utf8_to_wchar(&name, &size)); hash_value(val); } while (size && (*name & 0x80)); } while (size); done: if (hp) final(a,b,c); return hs[2]; } Dmitry - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Eric Paris | TALPA - a threat model? well sorta. |
| Vladislav Bolkhovitin | Re: Integration of SCST in the mainstream Linux kernel |
| Andrew Morton | Re: [BUILD-FAILURE] 2.6.26-rc8-mm1 - x86 - __ptep_modify_prot_start() missing |
| Bodo Eggert | Re: [PATCH] x86: provide a DMI based port 0x80 I/O delay override. |
git: | |
| Pavel Roskin | Implementing branch attributes in git config |
| Jon Smirl | Importing Mozilla CVS into git |
| Jon Smirl | Figured out how to get Mozilla into git |
| Jakub Narebski | Re: VCS comparison table |
| Richard Stallman | Real men don't attack straw men |
| Adam Getchell | Re: About Xen: maybe a reiterative question but .. |
| carlopmart | About Xen: maybe a reiterative question but .. |
| Bertram Scharpf | First install: Grub doesn't find partitions |
| Waskiewicz Jr, Peter P | RE: [PATCH 2/3][NET_BATCH] net core use batching |
| Jeff Kirsher | [PATCH 1/3] e1000e: add support for the 82567LM-4 device |
| Ayaz Abdulla | [PATCH] forcedeth: msi interrupts |
| Corey Hickey | [PATCH 10/10] Use nested compat attributes to pass parameters. |
