summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-02-25 22:20:10 (GMT)
committernijtmans <nijtmans>2010-02-25 22:20:10 (GMT)
commit98fb386a75b36633c9e4df45415e296bf62ec42f (patch)
treeffa352ca883f0018c5d14cbd41b0f6917c0a97ad /generic/tclObj.c
parent526e8665e559eb977cf2475cfcd08492be633a87 (diff)
downloadtcl-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/tclObj.c')
-rw-r--r--generic/tclObj.c15
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;
}