summaryrefslogtreecommitdiffstats
path: root/generic/tclHash.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-12-20 13:38:17 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-12-20 13:38:17 (GMT)
commit8bafabac9895be043d6bc198b1f1766240682ae6 (patch)
tree4057af9d22a34d893adece1a29ef67c9c2c20e4d /generic/tclHash.c
parent1bcaf97bfdcfc794caf8606cf3da5ddac8bc02d6 (diff)
parenta15b801bfb5d91ea33543a69ca112cfdd4a848bb (diff)
downloadtcl-8bafabac9895be043d6bc198b1f1766240682ae6.zip
tcl-8bafabac9895be043d6bc198b1f1766240682ae6.tar.gz
tcl-8bafabac9895be043d6bc198b1f1766240682ae6.tar.bz2
merge trunk
Diffstat (limited to 'generic/tclHash.c')
-rw-r--r--generic/tclHash.c62
1 files changed, 19 insertions, 43 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 3ea9f66..dc58800 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -14,13 +14,6 @@
#include "tclInt.h"
/*
- * Prevent macros from clashing with function definitions.
- */
-
-#undef Tcl_FindHashEntry
-#undef Tcl_CreateHashEntry
-
-/*
* When there are this many entries per bucket, on average, rebuild the hash
* table to make it larger.
*/
@@ -41,18 +34,18 @@
* Prototypes for the array hash key methods.
*/
-static Tcl_HashEntry * AllocArrayEntry(Tcl_HashTable *tablePtr, void *keyPtr);
-static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr);
-static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr);
+static Tcl_HashEntry * AllocArrayEntry(Tcl_HashTable *tablePtr, CONST90 void *keyPtr);
+static int CompareArrayKeys(CONST90 void *keyPtr, Tcl_HashEntry *hPtr);
+static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, CONST90 void *keyPtr);
/*
* Prototypes for the string hash key methods.
*/
static Tcl_HashEntry * AllocStringEntry(Tcl_HashTable *tablePtr,
- void *keyPtr);
-static int CompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr);
-static TCL_HASH_TYPE HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr);
+ CONST90 void *keyPtr);
+static int CompareStringKeys(CONST90 void *keyPtr, Tcl_HashEntry *hPtr);
+static TCL_HASH_TYPE HashStringKey(Tcl_HashTable *tablePtr, CONST90 void *keyPtr);
/*
* Function prototypes for static functions in this file:
@@ -200,7 +193,7 @@ Tcl_InitCustomHashTable(
/*
*----------------------------------------------------------------------
*
- * Tcl_FindHashEntry --
+ * FindHashEntry --
*
* Given a hash table find the entry with a matching key.
*
@@ -214,14 +207,6 @@ Tcl_InitCustomHashTable(
*----------------------------------------------------------------------
*/
-Tcl_HashEntry *
-Tcl_FindHashEntry(
- Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */
- const void *key) /* Key to use to find matching entry. */
-{
- return (*((tablePtr)->findProc))(tablePtr, key);
-}
-
static Tcl_HashEntry *
FindHashEntry(
Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */
@@ -234,7 +219,7 @@ FindHashEntry(
/*
*----------------------------------------------------------------------
*
- * Tcl_CreateHashEntry --
+ * CreateHashEntry --
*
* Given a hash table with string keys, and a string key, find the entry
* with a matching key. If there is no matching entry, then create a new
@@ -252,17 +237,6 @@ FindHashEntry(
*----------------------------------------------------------------------
*/
-Tcl_HashEntry *
-Tcl_CreateHashEntry(
- Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */
- const void *key, /* Key to use to find or create matching
- * entry. */
- int *newPtr) /* Store info here telling whether a new entry
- * was created. */
-{
- return (*((tablePtr)->createProc))(tablePtr, key, newPtr);
-}
-
static Tcl_HashEntry *
CreateHashEntry(
Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */
@@ -679,13 +653,13 @@ Tcl_HashStats(
static Tcl_HashEntry *
AllocArrayEntry(
Tcl_HashTable *tablePtr, /* Hash table. */
- void *keyPtr) /* Key to store in the hash table entry. */
+ CONST90 void *keyPtr) /* Key to store in the hash table entry. */
{
int *array = (int *) keyPtr;
register int *iPtr1, *iPtr2;
Tcl_HashEntry *hPtr;
int count;
- unsigned int size;
+ size_t size;
count = tablePtr->keyType;
@@ -723,7 +697,7 @@ AllocArrayEntry(
static int
CompareArrayKeys(
- void *keyPtr, /* New key to compare. */
+ CONST90 void *keyPtr, /* New key to compare. */
Tcl_HashEntry *hPtr) /* Existing key to compare. */
{
register const int *iPtr1 = (const int *) keyPtr;
@@ -763,7 +737,7 @@ CompareArrayKeys(
static TCL_HASH_TYPE
HashArrayKey(
Tcl_HashTable *tablePtr, /* Hash table. */
- void *keyPtr) /* Key from which to compute hash value. */
+ CONST90 void *keyPtr) /* Key from which to compute hash value. */
{
register const int *array = (const int *) keyPtr;
register TCL_HASH_TYPE result;
@@ -795,11 +769,11 @@ HashArrayKey(
static Tcl_HashEntry *
AllocStringEntry(
Tcl_HashTable *tablePtr, /* Hash table. */
- void *keyPtr) /* Key to store in the hash table entry. */
+ CONST90 void *keyPtr) /* Key to store in the hash table entry. */
{
const char *string = (const char *) keyPtr;
Tcl_HashEntry *hPtr;
- unsigned int size, allocsize;
+ size_t size, allocsize;
allocsize = size = strlen(string) + 1;
if (size < sizeof(hPtr->key)) {
@@ -830,7 +804,7 @@ AllocStringEntry(
static int
CompareStringKeys(
- void *keyPtr, /* New key to compare. */
+ CONST90 void *keyPtr, /* New key to compare. */
Tcl_HashEntry *hPtr) /* Existing key to compare. */
{
register const char *p1 = (const char *) keyPtr;
@@ -859,7 +833,7 @@ CompareStringKeys(
static TCL_HASH_TYPE
HashStringKey(
Tcl_HashTable *tablePtr, /* Hash table. */
- void *keyPtr) /* Key from which to compute hash value. */
+ CONST90 void *keyPtr) /* Key from which to compute hash value. */
{
register const char *string = keyPtr;
register TCL_HASH_TYPE result;
@@ -1025,7 +999,9 @@ RebuildTable(
*newChainPtr = NULL;
}
tablePtr->rebuildSize *= 4;
- tablePtr->downShift -= 2;
+ if (tablePtr->downShift > 1) {
+ tablePtr->downShift -= 2;
+ }
tablePtr->mask = (tablePtr->mask << 2) + 3;
/*