diff --git a/generic/tclInt.h b/generic/tclInt.h index 5ba5e0ed30b..d2a6a4ec6bc 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -243,15 +243,6 @@ typedef struct TclVarHashTable { #define TclVarHashFindVar(tablePtr, key) \ TclVarHashCreateVar((tablePtr), (key), NULL) -/* - * Define this to reduce the amount of space that the average namespace - * consumes by only allocating the table of child namespaces when necessary. - * Defining it breaks compatibility for Tcl extensions (e.g., itcl) which - * reach directly into the Namespace structure. - */ - -#undef BREAK_NAMESPACE_COMPAT - /* * The structure below defines a namespace. * Note: the first five fields must match exactly the fields in a @@ -274,15 +265,8 @@ typedef struct Namespace { struct Namespace *parentPtr;/* Points to the namespace that contains this * one. NULL if this is the global * namespace. */ -#ifndef BREAK_NAMESPACE_COMPAT Tcl_HashTable childTable; /* Contains any child namespaces. Indexed by * strings; values have type (Namespace *). */ -#else - Tcl_HashTable *childTablePtr; - /* Contains any child namespaces. Indexed by - * strings; values have type (Namespace *). If - * NULL, there are no children. */ -#endif unsigned long nsId; /* Unique id for the namespace. */ Tcl_Interp *interp; /* The interpreter containing this * namespace. */ diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 7c041c621ba..5773fee4830 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -750,12 +750,7 @@ Tcl_CreateNamespace( */ if ( -#ifndef BREAK_NAMESPACE_COMPAT Tcl_FindHashEntry(&parentPtr->childTable, simpleName) != NULL -#else - parentPtr->childTablePtr != NULL && - Tcl_FindHashEntry(parentPtr->childTablePtr, simpleName) != NULL -#endif ) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't create namespace \"%s\": already exists", name)); @@ -779,11 +774,7 @@ Tcl_CreateNamespace( nsPtr->clientData = clientData; nsPtr->deleteProc = deleteProc; nsPtr->parentPtr = parentPtr; -#ifndef BREAK_NAMESPACE_COMPAT Tcl_InitHashTable(&nsPtr->childTable, TCL_STRING_KEYS); -#else - nsPtr->childTablePtr = NULL; -#endif nsPtr->nsId = ++(tsdPtr->numNsCreated); nsPtr->interp = interp; nsPtr->flags = 0; @@ -1028,7 +1019,7 @@ Tcl_DeleteNamespace( * being deleted, ignore any second call. */ - nsPtr->flags |= NS_DYING | NS_TEARDOWN; + nsPtr->flags |= (NS_DYING | NS_TEARDOWN); TclTeardownNamespace(nsPtr); @@ -1042,14 +1033,7 @@ Tcl_DeleteNamespace( TclDeleteNamespaceVars(nsPtr); -#ifndef BREAK_NAMESPACE_COMPAT Tcl_DeleteHashTable(&nsPtr->childTable); -#else - if (nsPtr->childTablePtr != NULL) { - Tcl_DeleteHashTable(nsPtr->childTablePtr); - ckfree(nsPtr->childTablePtr); - } -#endif Tcl_DeleteHashTable(&nsPtr->cmdTable); nsPtr ->flags |= NS_DEAD; @@ -1102,7 +1086,6 @@ TclDeleteNamespaceChildren( * Important: leave the hash table itself still live. */ -#ifndef BREAK_NAMESPACE_COMPAT unchecked = (nsPtr->childTable.numEntries > 0); while (nsPtr->childTable.numEntries > 0 && unchecked) { size_t length = nsPtr->childTable.numEntries; @@ -1127,34 +1110,6 @@ TclDeleteNamespaceChildren( } TclStackFree((Tcl_Interp *) iPtr, children); } -#else - if (nsPtr->childTablePtr != NULL) { - unchecked = (nsPtr->childTable.numEntries > 0); - while (nsPtr->childTable.numEntries > 0 && unchecked) { - size_t length = nsPtr->childTablePtr->numEntries; - Namespace **children = (Namespace **)TclStackAlloc((Tcl_Interp *) iPtr, - sizeof(Namespace *) * length); - - i = 0; - for (entryPtr = Tcl_FirstHashEntry(nsPtr->childTablePtr, &search); - entryPtr != NULL; - entryPtr = Tcl_NextHashEntry(&search)) { - children[i] = (Namespace *)Tcl_GetHashValue(entryPtr); - children[i]->refCount++; - i++; - } - unchecked = 0; - for (i = 0 ; i < length ; i++) { - if (!(children[i]->flags & NS_DYING)) { - unchecked = 1; - Tcl_DeleteNamespace((Tcl_Namespace *) children[i]); - TclNsDecrRefCount(children[i]); - } - } - TclStackFree((Tcl_Interp *) iPtr, children); - } - } -#endif } /* @@ -2352,15 +2307,7 @@ TclGetNamespaceForQualName( */ if (nsPtr != NULL) { -#ifndef BREAK_NAMESPACE_COMPAT entryPtr = Tcl_FindHashEntry(&nsPtr->childTable, nsName); -#else - if (nsPtr->childTablePtr == NULL) { - entryPtr = NULL; - } else { - entryPtr = Tcl_FindHashEntry(nsPtr->childTablePtr, nsName); - } -#endif if (entryPtr != NULL) { nsPtr = (Namespace *)Tcl_GetHashValue(entryPtr); } else if (flags & TCL_CREATE_NS_IF_UNKNOWN) { @@ -2391,15 +2338,7 @@ TclGetNamespaceForQualName( */ if (altNsPtr != NULL) { -#ifndef BREAK_NAMESPACE_COMPAT entryPtr = Tcl_FindHashEntry(&altNsPtr->childTable, nsName); -#else - if (altNsPtr->childTablePtr != NULL) { - entryPtr = Tcl_FindHashEntry(altNsPtr->childTablePtr, nsName); - } else { - entryPtr = NULL; - } -#endif if (entryPtr != NULL) { altNsPtr = (Namespace *)Tcl_GetHashValue(entryPtr); } else { @@ -2824,17 +2763,8 @@ TclResetShadowedCmdRefs( for (i = trailFront; i >= 0; i--) { trailNsPtr = trailPtr[i]; -#ifndef BREAK_NAMESPACE_COMPAT hPtr = Tcl_FindHashEntry(&shadowNsPtr->childTable, trailNsPtr->name); -#else - if (shadowNsPtr->childTablePtr != NULL) { - hPtr = Tcl_FindHashEntry(shadowNsPtr->childTablePtr, - trailNsPtr->name); - } else { - hPtr = NULL; - } -#endif if (hPtr != NULL) { shadowNsPtr = (Namespace *)Tcl_GetHashValue(hPtr); } else { @@ -3086,27 +3016,13 @@ NamespaceChildrenCmd( /* * Global namespace members are prefixed with "::", others not. Ticket [63449c0514] */ - if ( -#ifndef BREAK_NAMESPACE_COMPAT - Tcl_FindHashEntry(&nsPtr->childTable, (nsPtr != globalNsPtr ? 2 : 0) + pattern+length) != NULL -#else - nsPtr->childTablePtr != NULL && - Tcl_FindHashEntry(nsPtr->childTablePtr, (nsPtr != globalNsPtr ? 2 : 0) + pattern+length) != NULL -#endif - ) { + if (Tcl_FindHashEntry(&nsPtr->childTable, (nsPtr != globalNsPtr ? 2 : 0) + pattern+length) != NULL) { Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(pattern, -1)); } goto searchDone; } -#ifndef BREAK_NAMESPACE_COMPAT entryPtr = Tcl_FirstHashEntry(&nsPtr->childTable, &search); -#else - if (nsPtr->childTablePtr == NULL) { - goto searchDone; - } - entryPtr = Tcl_FirstHashEntry(nsPtr->childTablePtr, &search); -#endif while (entryPtr != NULL) { childNsPtr = (Namespace *)Tcl_GetHashValue(entryPtr); if ((pattern == NULL) @@ -4902,15 +4818,7 @@ TclGetNamespaceChildTable( Tcl_Namespace *nsPtr) { Namespace *nPtr = (Namespace *) nsPtr; -#ifndef BREAK_NAMESPACE_COMPAT return &nPtr->childTable; -#else - if (nPtr->childTablePtr == NULL) { - nPtr->childTablePtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable)); - Tcl_InitHashTable(nPtr->childTablePtr, TCL_STRING_KEYS); - } - return nPtr->childTablePtr; -#endif } /* diff --git a/generic/tclResolve.c b/generic/tclResolve.c index ff88ffdfb1d..e5aaa81df5d 100644 --- a/generic/tclResolve.c +++ b/generic/tclResolve.c @@ -262,23 +262,12 @@ BumpCmdRefEpochs( nsPtr->cmdRefEpoch++; -#ifndef BREAK_NAMESPACE_COMPAT for (entry = Tcl_FirstHashEntry(&nsPtr->childTable, &search); entry != NULL; entry = Tcl_NextHashEntry(&search)) { Namespace *childNsPtr = (Namespace *)Tcl_GetHashValue(entry); BumpCmdRefEpochs(childNsPtr); } -#else - if (nsPtr->childTablePtr != NULL) { - for (entry = Tcl_FirstHashEntry(nsPtr->childTablePtr, &search); - entry != NULL; entry = Tcl_NextHashEntry(&search)) { - Namespace *childNsPtr = Tcl_GetHashValue(entry); - - BumpCmdRefEpochs(childNsPtr); - } - } -#endif TclInvalidateNsPath(nsPtr); }