diff options
author | nijtmans <nijtmans> | 2010-02-25 22:20:10 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-02-25 22:20:10 (GMT) |
commit | 98fb386a75b36633c9e4df45415e296bf62ec42f (patch) | |
tree | ffa352ca883f0018c5d14cbd41b0f6917c0a97ad /generic/tclHash.c | |
parent | 526e8665e559eb977cf2475cfcd08492be633a87 (diff) | |
download | tcl-98fb386a75b36633c9e4df45415e296bf62ec42f.zip tcl-98fb386a75b36633c9e4df45415e296bf62ec42f.tar.gz tcl-98fb386a75b36633c9e4df45415e296bf62ec42f.tar.bz2 |
[ tcl-Feature Requests-2958832 ] Further
speed-up of ouster-hash function.
Eliminate various unnecessary (ClientData)
type casts.
Diffstat (limited to 'generic/tclHash.c')
-rw-r--r-- | generic/tclHash.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c index a7d6b40..7647db0 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclHash.c,v 1.44 2010/02/24 10:45:04 dkf Exp $ + * RCS: @(#) $Id: tclHash.c,v 1.45 2010/02/25 22:20:10 nijtmans Exp $ */ #include "tclInt.h" @@ -871,8 +871,8 @@ HashStringKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ { - register const char *string = (const char *) keyPtr; - register unsigned int result = 0; + register const char *string = keyPtr; + register unsigned int result; register char c; /* @@ -903,10 +903,14 @@ HashStringKey( * * See also HashString in tclLiteral.c. * See also TclObjHashKey in tclObj.c. + * + * See [tcl-Feature Request #2958832] */ - for (; (c=*string++) != 0 ;) { - result += (result<<3) + UCHAR(c); + if ((result = UCHAR(*string)) != 0) { + while ((c = *++string) != 0) { + result += (result << 3) + UCHAR(c); + } } return result; } |