summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-03-30 14:22:30 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-03-30 14:22:30 (GMT)
commit18602aa3752175c93bc985c5c13cde3f0f9fb3ee (patch)
tree40a5e67b211a69a71edc7de3a63659abc08e4efb /generic/tclExecute.c
parent9a08b056c6086eb886da58e32ce8efae27b13b25 (diff)
downloadtcl-18602aa3752175c93bc985c5c13cde3f0f9fb3ee.zip
tcl-18602aa3752175c93bc985c5c13cde3f0f9fb3ee.tar.gz
tcl-18602aa3752175c93bc985c5c13cde3f0f9fb3ee.tar.bz2
* generic/tclExecute.c: optimise the lookup of elements of indexed
arrays.
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 415412f..2ed4e7d 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -12,7 +12,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.264 2007/03/22 18:19:47 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.265 2007/03/30 14:22:30 msofer Exp $
*/
#include "tclInt.h"
@@ -2049,12 +2049,26 @@ TclExecuteByteCode(
arrayPtr = arrayPtr->value.linkPtr;
}
TRACE(("%u \"%.30s\" => ", opnd, part2));
- varPtr = TclLookupArrayElement(interp, part1, part2,
- TCL_LEAVE_ERR_MSG, "read", 0, 1, arrayPtr);
+ if (!TclIsVarUndefined(arrayPtr)
+ && TclIsVarArray(arrayPtr)
+ && TclIsVarUntraced(arrayPtr)) {
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(arrayPtr->value.tablePtr, part2);
+ if (hPtr == NULL) {
+ varPtr = NULL;
+ } else {
+ varPtr = (Var *) Tcl_GetHashValue(hPtr);
+ }
+ } else {
+ varPtr = NULL;
+ }
if (varPtr == NULL) {
- TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
- goto checkForCatch;
+ varPtr = TclLookupArrayElement(interp, part1, part2,
+ TCL_LEAVE_ERR_MSG, "read", 0, 1, arrayPtr);
+ if (varPtr == NULL) {
+ TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
+ result = TCL_ERROR;
+ goto checkForCatch;
+ }
}
if (TclIsVarDirectReadable(varPtr)
&& ((arrayPtr == NULL) || TclIsVarUntraced(arrayPtr))) {
@@ -2213,12 +2227,26 @@ TclExecuteByteCode(
while (TclIsVarLink(arrayPtr)) {
arrayPtr = arrayPtr->value.linkPtr;
}
- varPtr = TclLookupArrayElement(interp, part1, part2,
- TCL_LEAVE_ERR_MSG, "set", 1, 1, arrayPtr);
+ if (!TclIsVarUndefined(arrayPtr)
+ && TclIsVarArray(arrayPtr)
+ && TclIsVarUntraced(arrayPtr)) {
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(arrayPtr->value.tablePtr, part2);
+ if (hPtr == NULL) {
+ varPtr = NULL;
+ } else {
+ varPtr = (Var *) Tcl_GetHashValue(hPtr);
+ }
+ } else {
+ varPtr = NULL;
+ }
if (varPtr == NULL) {
- TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
- goto checkForCatch;
+ varPtr = TclLookupArrayElement(interp, part1, part2,
+ TCL_LEAVE_ERR_MSG, "set", 1, 1, arrayPtr);
+ if (varPtr == NULL) {
+ TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
+ result = TCL_ERROR;
+ goto checkForCatch;
+ }
}
cleanup = 2;
goto doCallPtrSetVar;