From edf6059e1c03b2bdef9a4f6aa85905ce19e9c5d9 Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Thu, 30 Aug 2001 12:04:13 +0000 Subject: 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]. --- ChangeLog | 8 ++++++++ generic/tclExecute.c | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8dcca50..07fce2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-08-30 Miguel Sofer + + * generic/tclExecute.c: 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]. + 2001-08-30 Vince Darley Further fs updates. After examining the most common Tcl 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; } -- cgit v0.12