summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2001-08-30 12:04:13 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2001-08-30 12:04:13 (GMT)
commitedf6059e1c03b2bdef9a4f6aa85905ce19e9c5d9 (patch)
treee222ff78b19930a2dc2bd9ea6b68fe5d687ce25f
parent209cbd9eea8f0938d87548bdea9bd8970d18a1fb (diff)
downloadtcl-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].
-rw-r--r--ChangeLog8
-rw-r--r--generic/tclExecute.c20
2 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8dcca50..07fce2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-08-30 Miguel Sofer <msofer@users.sourceforge.net>
+
+ * 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 <vincentdarley@users.sourceforge.net>
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;
}