From b56947219139a3ea4cd1fa607c4fb4a2aea1b292 Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 2 Jul 2007 20:30:44 +0000 Subject: Simplify string hashing a little. [FRQ 951168] --- ChangeLog | 11 +++++++++-- generic/tclHash.c | 16 ++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdd0b4c..6fc9b82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-07-02 Donal K. Fellows + + * 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 * generic/tclIO.c: Removed dead code. @@ -9,8 +16,8 @@ 2007-06-30 Donal K. Fellows - * 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 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 { -- cgit v0.12