From: Marius Vollmer <mvo@zagadka.de>
Cc: guile-user@gnu.org
Subject: Re: Does anyone have a better scm_string_hash ?
Date: Mon, 17 Nov 2003 16:42:35 +0100 [thread overview]
Message-ID: <874qx3rogk.fsf@zagadka.ping.de> (raw)
In-Reply-To: <1069058032.1638.21.camel@localhost> (Roland Orre's message of "Mon, 17 Nov 2003 09:33:53 +0100")
Roland Orre <orre@nada.kth.se> writes:
> /* replaced by Roland Orre orre@nada.kth.se */
> #define hash_mask 0x00FFFFFF
> unsigned long
> scm_string_hash (const unsigned char *str, size_t len)
> {
> /* from suggestion at: */
> /* http://srfi.schemers.org/srfi-13/mail-archive/msg00112.html */
> int i;
> /* originally h=0 was suggested. orre@nada.kth.se */
> unsigned long h=177;
>
> for (i = len-1; i >= 0; i--)
> {
> /* h = (str[i] +i+ h*37) & hash_mask; */
> h = (str[i] + i + (h<<5) + (h<<2) + h) & hash_mask;
> }
> return h;
> } /* scm_string_hash */
g_string_hash from glib uses the same approach, but with 31 instead of
37 and with a h=0 seed:
/* 31 bit hash function */
guint
g_str_hash (gconstpointer key)
{
const char *p = key;
guint h = *p;
if (h)
for (p += 1; *p != '\0'; p++)
h = (h << 5) - h + *p;
return h;
}
So which one is it? :)
Both should be much better than the one we have right now and I'm
going to install the one from Roland without the hash_mask.
OK?
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2003-11-17 15:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-13 21:55 cmod-play 1 available + modsup.h additions Thien-Thi Nguyen
2003-11-14 8:26 ` Ludovic Courtès
2003-11-14 13:10 ` Thien-Thi Nguyen
2003-11-14 13:37 ` Ludovic Courtès
2003-11-14 17:38 ` Thien-Thi Nguyen
2003-11-14 14:29 ` Marius Vollmer
2003-11-14 14:17 ` Marius Vollmer
2003-11-14 15:28 ` Does anyone have a better scm_string_hash ? Roland Orre
2003-11-14 15:51 ` Ludovic Courtès
2003-11-17 8:33 ` Roland Orre
2003-11-17 13:01 ` Ludovic Courtès
2003-11-17 15:42 ` Marius Vollmer [this message]
2003-11-17 16:02 ` Marius Vollmer
2003-11-17 16:29 ` Marius Vollmer
2003-11-17 16:48 ` Allister MacLeod
2003-11-17 17:57 ` Marius Vollmer
2003-11-17 19:17 ` OT: x86 assembly timings/size (was Re: Does anyone have a better scm_string_hash ?) Allister MacLeod
2003-11-17 21:27 ` OT: x86 assembly timings/size Marius Vollmer
2003-11-19 9:04 ` Does anyone have a better scm_string_hash ? Ludovic Courtès
2003-11-19 15:02 ` Marius Vollmer
2003-11-14 17:40 ` cmod-play 1 available + modsup.h additions Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874qx3rogk.fsf@zagadka.ping.de \
--to=mvo@zagadka.de \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).