summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-03-30 23:34:21 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-03-30 23:34:21 (GMT)
commitd6dc5f9be580f37147098a4354643545002a63ee (patch)
tree012b37bb9d24ea285e4baef2110bf4db12734c1c /generic
parentfc35db336cf80ba5d03d87e2d0c86edf1670d8fc (diff)
downloadtcl-d6dc5f9be580f37147098a4354643545002a63ee.zip
tcl-d6dc5f9be580f37147098a4354643545002a63ee.tar.gz
tcl-d6dc5f9be580f37147098a4354643545002a63ee.tar.bz2
Backport of fixes to make HashObjKey hash the whole object...
Diffstat (limited to 'generic')
-rw-r--r--generic/tclObj.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c
index a98fe1c..b1183c3 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclObj.c,v 1.42.2.4 2003/05/23 21:29:11 dgp Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.42.2.5 2004/03/30 23:34:21 dkf Exp $
*/
#include "tclInt.h"
@@ -2717,9 +2717,9 @@ CompareObjKeys(keyPtr, hPtr)
* Don't use Tcl_GetStringFromObj as it would prevent l1 and l2 being
* in a register.
*/
- p1 = Tcl_GetString (objPtr1);
+ p1 = TclGetString(objPtr1);
l1 = objPtr1->length;
- p2 = Tcl_GetString (objPtr2);
+ p2 = TclGetString(objPtr2);
l2 = objPtr2->length;
/*
@@ -2789,14 +2789,11 @@ HashObjKey(tablePtr, keyPtr)
VOID *keyPtr; /* Key from which to compute hash value. */
{
Tcl_Obj *objPtr = (Tcl_Obj *) keyPtr;
- register CONST char *string;
- register int length;
- register unsigned int result;
- register int c;
+ CONST char *string = TclGetString(objPtr);
+ int length = objPtr->length;
+ unsigned int result;
+ int i;
- string = Tcl_GetString (objPtr);
- length = objPtr->length;
-
/*
* I tried a zillion different hash functions and asked many other
* people for advice. Many people had their own favorite functions,
@@ -2814,14 +2811,8 @@ HashObjKey(tablePtr, keyPtr)
*/
result = 0;
- while (length) {
- c = *string;
- string++;
- length--;
- if (length == 0) {
- break;
- }
- result += (result<<3) + c;
+ for (i=0 ; i<length ; i++) {
+ result += (result<<3) + string[i];
}
return result;
}