summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-15 10:33:09 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-15 10:33:09 (GMT)
commitdf25840e9998ccae184ac0e650ea1857d1da6634 (patch)
tree51cc000ee2e6f9906b62e50a777252dfdfae82ad /generic/tclCompile.c
parentf1d71456ca0ed0f306f2fdfbaf3668e506f41aa9 (diff)
downloadtcl-df25840e9998ccae184ac0e650ea1857d1da6634.zip
tcl-df25840e9998ccae184ac0e650ea1857d1da6634.tar.gz
tcl-df25840e9998ccae184ac0e650ea1857d1da6634.tar.bz2
Eliminate AuxDataType table: since this table only contains 4 constant entries, it is overkill to use a hash table for that.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c156
1 files changed, 10 insertions, 146 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index f62ec14..6c4734d 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -17,15 +17,6 @@
#include <assert.h>
/*
- * Table of all AuxData types.
- */
-
-static Tcl_HashTable auxDataTypeTable;
-static int auxDataTypeTableInitialized; /* 0 means not yet initialized. */
-
-TCL_DECLARE_MUTEX(tableMutex)
-
-/*
* Variable that controls whether compilation tracing is enabled and, if so,
* what level of tracing is desired:
* 0: no compilation tracing
@@ -4221,59 +4212,6 @@ TclGetInstructionTable(void)
}
/*
- *--------------------------------------------------------------
- *
- * RegisterAuxDataType --
- *
- * This procedure is called to register a new AuxData type in the table
- * of all AuxData types supported by Tcl.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The type is registered in the AuxData type table. If there was already
- * a type with the same name as in typePtr, it is replaced with the new
- * type.
- *
- *--------------------------------------------------------------
- */
-
-static void
-RegisterAuxDataType(
- const AuxDataType *typePtr) /* Information about object type; storage must
- * be statically allocated (must live forever;
- * will not be deallocated). */
-{
- register Tcl_HashEntry *hPtr;
- int isNew;
-
- Tcl_MutexLock(&tableMutex);
- if (!auxDataTypeTableInitialized) {
- TclInitAuxDataTypeTable();
- }
-
- /*
- * If there's already a type with the given name, remove it.
- */
-
- hPtr = Tcl_FindHashEntry(&auxDataTypeTable, typePtr->name);
- if (hPtr != NULL) {
- Tcl_DeleteHashEntry(hPtr);
- }
-
- /*
- * Now insert the new object type.
- */
-
- hPtr = Tcl_CreateHashEntry(&auxDataTypeTable, typePtr->name, &isNew);
- if (isNew) {
- Tcl_SetHashValue(hPtr, typePtr);
- }
- Tcl_MutexUnlock(&tableMutex);
-}
-
-/*
*----------------------------------------------------------------------
*
* TclGetAuxDataType --
@@ -4294,90 +4232,16 @@ const AuxDataType *
TclGetAuxDataType(
const char *typeName) /* Name of AuxData type to look up. */
{
- register Tcl_HashEntry *hPtr;
- const AuxDataType *typePtr = NULL;
-
- Tcl_MutexLock(&tableMutex);
- if (!auxDataTypeTableInitialized) {
- TclInitAuxDataTypeTable();
- }
-
- hPtr = Tcl_FindHashEntry(&auxDataTypeTable, typeName);
- if (hPtr != NULL) {
- typePtr = Tcl_GetHashValue(hPtr);
- }
- Tcl_MutexUnlock(&tableMutex);
-
- return typePtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TclInitAuxDataTypeTable --
- *
- * This procedure is invoked to perform once-only initialization of the
- * AuxData type table. It also registers the AuxData types defined in
- * this file.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Initializes the table of defined AuxData types "auxDataTypeTable" with
- * builtin AuxData types defined in this file.
- *
- *--------------------------------------------------------------
- */
-
-void
-TclInitAuxDataTypeTable(void)
-{
- /*
- * The table mutex must already be held before this routine is invoked.
- */
-
- auxDataTypeTableInitialized = 1;
- Tcl_InitHashTable(&auxDataTypeTable, TCL_STRING_KEYS);
-
- /*
- * There are only four AuxData types at this time, so register them here.
- */
-
- RegisterAuxDataType(&tclForeachInfoType);
- RegisterAuxDataType(&tclNewForeachInfoType);
- RegisterAuxDataType(&tclJumptableInfoType);
- RegisterAuxDataType(&tclDictUpdateInfoType);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclFinalizeAuxDataTypeTable --
- *
- * This procedure is called by Tcl_Finalize after all exit handlers have
- * been run to free up storage associated with the table of AuxData
- * types. This procedure is called by TclFinalizeExecution() which is
- * called by Tcl_Finalize().
- *
- * Results:
- * None.
- *
- * Side effects:
- * Deletes all entries in the hash table of AuxData types.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclFinalizeAuxDataTypeTable(void)
-{
- Tcl_MutexLock(&tableMutex);
- if (auxDataTypeTableInitialized) {
- Tcl_DeleteHashTable(&auxDataTypeTable);
- auxDataTypeTableInitialized = 0;
- }
- Tcl_MutexUnlock(&tableMutex);
+ if (!strcmp(typeName, tclForeachInfoType.name)) {
+ return &tclForeachInfoType;
+ } else if (!strcmp(typeName, tclNewForeachInfoType.name)) {
+ return &tclNewForeachInfoType;
+ } else if (!strcmp(typeName, tclDictUpdateInfoType.name)) {
+ return &tclDictUpdateInfoType;
+ } else if (!strcmp(typeName, tclJumptableInfoType.name)) {
+ return &tclJumptableInfoType;
+ }
+ return NULL;
}
/*