diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-07-02 20:30:44 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-07-02 20:30:44 (GMT) |
commit | b56947219139a3ea4cd1fa607c4fb4a2aea1b292 (patch) | |
tree | 5f2b0e7e1e3b5b9976a0897890dc730f9110ae48 | |
parent | 6815029e55cbb1f53e50d279923c2cf0218b42d2 (diff) | |
download | tcl-b56947219139a3ea4cd1fa607c4fb4a2aea1b292.zip tcl-b56947219139a3ea4cd1fa607c4fb4a2aea1b292.tar.gz tcl-b56947219139a3ea4cd1fa607c4fb4a2aea1b292.tar.bz2 |
Simplify string hashing a little. [FRQ 951168]
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | generic/tclHash.c | 16 |
2 files changed, 11 insertions, 16 deletions
@@ -1,3 +1,10 @@ +2007-07-02 Donal K. Fellows <dkf@users.sf.net> + + * generic/tclHash.c (CompareStringKeys): Always use the strcmp() + version; the operation is functionally equivalent, the speed is + identical (up to measurement limitations), and yet the code is + simpler. [FRQ 951168] + 2007-07-02 Don Porter <dgp@users.sourceforge.net> * generic/tclIO.c: Removed dead code. @@ -9,8 +16,8 @@ 2007-06-30 Donal K. Fellows <dkf@users.sf.net> - * generic/tclCmdIL.c (Tcl_LsortObjCmd): Plug a memory leak caused by - a missing Tcl_DecrRefCount on an error path. [Bug 1717186] + * generic/tclCmdIL.c (Tcl_LsortObjCmd): Plug a memory leak caused by a + missing Tcl_DecrRefCount on an error path. [Bug 1717186] 2007-06-30 Zoran Vasiljevic <vasiljevic@users.sourceforge.net> diff --git a/generic/tclHash.c b/generic/tclHash.c index 8be7d1f..3bb863d 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.29 2007/04/17 14:49:53 dkf Exp $ + * RCS: @(#) $Id: tclHash.c,v 1.30 2007/07/02 20:30:50 dkf Exp $ */ #include "tclInt.h" @@ -925,19 +925,7 @@ CompareStringKeys( register const char *p1 = (const char *) keyPtr; register const char *p2 = (const char *) hPtr->key.string; -#ifdef TCL_COMPARE_HASHES_WITH_STRCMP return !strcmp(p1, p2); -#else - for (;; p1++, p2++) { - if (*p1 != *p2) { - break; - } - if (*p1 == '\0') { - return 1; - } - } - return 0; -#endif /* TCL_COMPARE_HASHES_WITH_STRCMP */ } /* @@ -1139,7 +1127,7 @@ RebuildTable( if (typePtr->hashKeyProc) { unsigned int hash; - hash = typePtr->hashKeyProc(tablePtr, (VOID *) key); + hash = typePtr->hashKeyProc(tablePtr, key); if (typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) { index = RANDOM_INDEX (tablePtr, hash); } else { |