diff options
author | nijtmans <nijtmans@noemail.net> | 2010-02-25 22:20:09 (GMT) |
---|---|---|
committer | nijtmans <nijtmans@noemail.net> | 2010-02-25 22:20:09 (GMT) |
commit | ecd98056a8e9ec5093a6aed679994573205c28bb (patch) | |
tree | ffa352ca883f0018c5d14cbd41b0f6917c0a97ad /generic/tclObj.c | |
parent | e0f5f0782b4fd5df7cd047da9195177ccacc5ae9 (diff) | |
download | tcl-ecd98056a8e9ec5093a6aed679994573205c28bb.zip tcl-ecd98056a8e9ec5093a6aed679994573205c28bb.tar.gz tcl-ecd98056a8e9ec5093a6aed679994573205c28bb.tar.bz2 |
[ tcl-Feature Requests-2958832 ] Further
speed-up of ouster-hash function.
Eliminate various unnecessary (ClientData)
type casts.
FossilOrigin-Name: b28fef8499c8d600688681143264f48ed28a8ead
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index 05bba4d..8123213 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -13,7 +13,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.170 2010/02/24 10:45:04 dkf Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.171 2010/02/25 22:20:10 nijtmans Exp $ */ #include "tclInt.h" @@ -4037,9 +4037,9 @@ TclHashObjKey( void *keyPtr) /* Key from which to compute hash value. */ { Tcl_Obj *objPtr = keyPtr; - const char *string = TclGetString(objPtr); + int length; + const char *string = TclGetStringFromObj(objPtr, &length); unsigned int result = 0; - const char *end = string + objPtr->length; /* * I tried a zillion different hash functions and asked many other people @@ -4071,10 +4071,15 @@ TclHashObjKey( * * See also HashStringKey in tclHash.c. * See also HashString in tclLiteral.c. + * + * See [tcl-Feature Request #2958832] */ - while (string < end) { - result += (result << 3) + UCHAR(*string++); + if (length > 0) { + result = UCHAR(*string); + while (--length) { + result += (result << 3) + UCHAR(*++string); + } } return result; } |