summaryrefslogtreecommitdiffstats
path: root/generic/tclLiteral.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/tclLiteral.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/tclLiteral.c')
-rw-r--r--generic/tclLiteral.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index bcf2bd8..a456627 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.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: tclLiteral.c,v 1.41 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclLiteral.c,v 1.42 2010/02/25 22:20:10 nijtmans Exp $
*/
#include "tclInt.h"
@@ -33,7 +33,7 @@
static int AddLocalLiteralEntry(CompileEnv *envPtr,
Tcl_Obj *objPtr, int localHash);
static void ExpandLocalLiteralArray(CompileEnv *envPtr);
-static unsigned HashString(const char *bytes, int length);
+static unsigned HashString(const char *string, int length);
static void RebuildLiteralTable(LiteralTable *tablePtr);
/*
@@ -891,11 +891,10 @@ TclReleaseLiteral(
static unsigned
HashString(
- register const char *bytes, /* String for which to compute hash value. */
+ register const char *string, /* String for which to compute hash value. */
int length) /* Number of bytes in the string. */
{
register unsigned int result = 0;
- register int i;
/*
* I tried a zillion different hash functions and asked many other people
@@ -923,10 +922,15 @@ HashString(
*
* See also HashStringKey in tclHash.c.
* See also TclObjHashKey in tclObj.c.
+ *
+ * See [tcl-Feature Request #2958832]
*/
- for (i=0; i<length ; i++) {
- result += (result<<3) + UCHAR(bytes[i]);
+ if (length > 0) {
+ result = UCHAR(*string);
+ while (--length) {
+ result += (result << 3) + UCHAR(*++string);
+ }
}
return result;
}