diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2001-08-30 12:04:13 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2001-08-30 12:04:13 (GMT) |
commit | edf6059e1c03b2bdef9a4f6aa85905ce19e9c5d9 (patch) | |
tree | e222ff78b19930a2dc2bd9ea6b68fe5d687ce25f /generic/tclExecute.c | |
parent | 209cbd9eea8f0938d87548bdea9bd8970d18a1fb (diff) | |
download | tcl-edf6059e1c03b2bdef9a4f6aa85905ce19e9c5d9.zip tcl-edf6059e1c03b2bdef9a4f6aa85905ce19e9c5d9.tar.gz tcl-edf6059e1c03b2bdef9a4f6aa85905ce19e9c5d9.tar.bz2 |
allow cached fully-qualified command names to be usable from different
namespaces within the same interpreter without forcing a new lookup. This speeds up scripts that pass command names in variables ("this" in some OO packages). [Patch 456668].
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index bf98c8d..97bb5ee 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.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: tclExecute.c,v 1.26 2001/07/03 23:39:10 hobbs Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.27 2001/08/30 12:04:13 msofer Exp $ */ #include "tclInt.h" @@ -5337,6 +5337,22 @@ Tcl_GetCommandFromObj(interp, objPtr) register Command *cmdPtr; Namespace *currNsPtr; int result; + CallFrame *savedFramePtr; + char *name; + + /* + * If the variable name is fully qualified, do as if the lookup were + * done from the global namespace; this helps avoid repeated lookups + * of fully qualified names. It costs close to nothing, and may be very + * helpful for OO applications which pass along a command name ("this"), + * [Patch 456668] + */ + + savedFramePtr = iPtr->varFramePtr; + name = Tcl_GetString(objPtr); + if ((*name++ == ':') && (*name == ':')) { + iPtr->varFramePtr = NULL; + } /* * Get the internal representation, converting to a command type if @@ -5347,6 +5363,7 @@ Tcl_GetCommandFromObj(interp, objPtr) if (objPtr->typePtr != &tclCmdNameType) { result = tclCmdNameType.setFromAnyProc(interp, objPtr); if (result != TCL_OK) { + iPtr->varFramePtr = savedFramePtr; return (Tcl_Command) NULL; } } @@ -5393,6 +5410,7 @@ Tcl_GetCommandFromObj(interp, objPtr) cmdPtr = resPtr->cmdPtr; } } + iPtr->varFramePtr = savedFramePtr; return (Tcl_Command) cmdPtr; } |