diff options
author | dkf <dkf@noemail.net> | 2004-03-30 23:34:21 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2004-03-30 23:34:21 (GMT) |
commit | a92d9d202a62cb12fa652e5c0a13f5d12ca0effb (patch) | |
tree | 012b37bb9d24ea285e4baef2110bf4db12734c1c /generic/tclObj.c | |
parent | d4414d0cc86c198f8f709002987947cbcfacb8c7 (diff) | |
download | tcl-a92d9d202a62cb12fa652e5c0a13f5d12ca0effb.zip tcl-a92d9d202a62cb12fa652e5c0a13f5d12ca0effb.tar.gz tcl-a92d9d202a62cb12fa652e5c0a13f5d12ca0effb.tar.bz2 |
Backport of fixes to make HashObjKey hash the whole object...
FossilOrigin-Name: 65765fe7bf31e0822047e8ccbf5b8d49531cc799
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 27 |
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; } |