Attachment "nsName.patch" to
ticket [458872ffff]
added by
msofer
2001-09-06 03:17:39.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.569
diff -u -r1.569 ChangeLog
--- ChangeLog 2001/09/05 08:21:18 1.569
+++ ChangeLog 2001/09/05 20:04:49
@@ -1,3 +1,9 @@
+2001-08-30 Miguel Sofer <[email protected]>
+
+ * generic/tclNamespace.c: allow cached fully-qualified namespace
+ names to be usable from different namespaces within the same
+ interpreter without forcing a new lookup.
+
2001-09-05 Vince Darley <[email protected]>
* tests/winFCmd.test: made notWin2000 constraint false if not
Index: generic/tclNamesp.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclNamesp.c,v
retrieving revision 1.25
diff -u -r1.25 tclNamesp.c
--- generic/tclNamesp.c 2001/06/28 12:43:33 1.25
+++ generic/tclNamesp.c 2001/09/05 20:04:51
@@ -2363,12 +2363,29 @@
* of a namespace. */
Tcl_Namespace **nsPtrPtr; /* Result namespace pointer goes here. */
{
+ Interp *iPtr = (Interp *) interp;
register ResolvedNsName *resNamePtr;
register Namespace *nsPtr;
- Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
+ Namespace *currNsPtr;
+ CallFrame *savedFramePtr;
int result;
+ char *name;
/*
+ * If the namespace name is fully qualified, do as if the lookup were
+ * done from the global namespace; this helps avoid repeated lookups
+ * of fully qualified names.
+ */
+
+ savedFramePtr = iPtr->varFramePtr;
+ name = Tcl_GetString(objPtr);
+ if ((*name++ == ':') && (*name == ':')) {
+ iPtr->varFramePtr = NULL;
+ }
+
+ currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
+
+ /*
* Get the internal representation, converting to a namespace type if
* needed. The internal representation is a ResolvedNsName that points
* to the actual namespace.
@@ -2377,6 +2394,7 @@
if (objPtr->typePtr != &tclNsNameType) {
result = tclNsNameType.setFromAnyProc(interp, objPtr);
if (result != TCL_OK) {
+ iPtr->varFramePtr = savedFramePtr;
return TCL_ERROR;
}
}
@@ -2403,6 +2421,7 @@
if (nsPtr == NULL) { /* try again */
result = tclNsNameType.setFromAnyProc(interp, objPtr);
if (result != TCL_OK) {
+ iPtr->varFramePtr = savedFramePtr;
return TCL_ERROR;
}
resNamePtr = (ResolvedNsName *) objPtr->internalRep.otherValuePtr;
@@ -2414,6 +2433,7 @@
}
}
*nsPtrPtr = (Tcl_Namespace *) nsPtr;
+ iPtr->varFramePtr = savedFramePtr;
return TCL_OK;
}