From 253cc1754bd6a3ebf97906bfaafb7e44647350c5 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Mon, 22 Aug 2022 17:42:32 -0700 Subject: [PATCH] Shave another 2% off GNU Make latency --- third_party/make/hash.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/third_party/make/hash.c b/third_party/make/hash.c index 7bf5904e5..7023cdc69 100644 --- a/third_party/make/hash.c +++ b/third_party/make/hash.c @@ -17,7 +17,9 @@ this program. If not, see . */ #include "third_party/make/makeint.inc" /**/ #include "libc/assert.h" +#include "libc/intrin/bits.h" #include "libc/intrin/likely.h" +#include "libc/log/check.h" #include "libc/nexgen32e/bsr.h" #include "third_party/make/hash.h" /* clang-format off */ @@ -442,27 +444,35 @@ jhash_string(unsigned const char *k) /* Set up the internal state */ a = b = c = JHASH_INITVAL; + for (; klen > 12; k += 12, klen -= 12) + { + a += READ32LE (k + 0); + b += READ32LE (k + 4); + c += READ32LE (k + 8); + jhash_mix (a, b, c); + } + /* All but the last block: affect some 32 bits of (a,b,c) */ for (;;) { sum_up_to_nul(a, k, klen, have_nul); if (have_nul) break; k += UINTSZ; - assert (klen >= UINTSZ); + DCHECK (klen >= UINTSZ); klen -= UINTSZ; sum_up_to_nul(b, k, klen, have_nul); if (have_nul) break; k += UINTSZ; - assert (klen >= UINTSZ); + DCHECK (klen >= UINTSZ); klen -= UINTSZ; sum_up_to_nul(c, k, klen, have_nul); if (have_nul) break; k += UINTSZ; - assert (klen >= UINTSZ); + DCHECK (klen >= UINTSZ); klen -= UINTSZ; jhash_mix(a, b, c); }