From 34e195626725c4cef5dc2d154497543223661aa0 Mon Sep 17 00:00:00 2001 From: mccallum Date: Thu, 22 Feb 1996 21:50:25 +0000 Subject: [PATCH] ([String -hash]): Don't use elt_* function, and use NSHashStringLength. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@983 72102866-910b-0410-8b05-ffd578937521 --- Source/String.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/String.m b/Source/String.m index e6456e5ba..56ea2c457 100644 --- a/Source/String.m +++ b/Source/String.m @@ -278,7 +278,17 @@ - (unsigned) hash { - return elt_hash_string([self cString]); + unsigned ret = 0; + unsigned ctr = 0; + unsigned char_count = 0; + const char *s = [self cStringNoCopy]; + + while (*s && char_count++ < NSHashStringLength) + { + ret ^= *s++ << ctr; + ctr = (ctr + 1) % sizeof (void*); + } + return ret; } - (int) compare: anObject