summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdAH.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-03-23 03:07:58 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-03-23 03:07:58 (GMT)
commit9f06ebf0ccc28723d30db49bb6e25380753cd7ae (patch)
treec26ec6bae3c120f2d324910e9ad84582634e163d /generic/tclCmdAH.c
parent26c2fe200e08a3dcf30a4def881bd87070579cc8 (diff)
downloadtcl-9f06ebf0ccc28723d30db49bb6e25380753cd7ae.zip
tcl-9f06ebf0ccc28723d30db49bb6e25380753cd7ae.tar.gz
tcl-9f06ebf0ccc28723d30db49bb6e25380753cd7ae.tar.bz2
Reduce number of StackAlloc and StackFree calls.
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r--generic/tclCmdAH.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 53032c6..66d95d5 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.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: tclCmdAH.c,v 1.86 2007/03/22 20:53:23 dgp Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.87 2007/03/23 03:07:58 dgp Exp $
*/
#include "tclInt.h"
@@ -1722,26 +1722,20 @@ Tcl_ForeachObjCmd(
* index[i] is the current pointer into the value list argvList[i].
*/
- index = (int *) TclStackAlloc(interp, numLists * sizeof(int));
- varcList = (int *) TclStackAlloc(interp, numLists * sizeof(int));
+ index = (int *) TclStackAlloc(interp, 3 * numLists * sizeof(int));
+ varcList = index + numLists;
+ argcList = varcList + numLists;
+ memset(index, 0, 3 * numLists * sizeof(int));
+
varvList = (Tcl_Obj ***)
- TclStackAlloc(interp, numLists * sizeof(Tcl_Obj **));
+ TclStackAlloc(interp, 2 * numLists * sizeof(Tcl_Obj **));
+ argvList = varvList + numLists;
+ memset(varvList, 0, 2 * numLists * sizeof(Tcl_Obj **));
+
vCopyList = (Tcl_Obj **)
- TclStackAlloc(interp, numLists * sizeof(Tcl_Obj *));
- argcList = (int *) TclStackAlloc(interp, numLists * sizeof(int));
- argvList = (Tcl_Obj ***)
- TclStackAlloc(interp, numLists * sizeof(Tcl_Obj **));
- aCopyList = (Tcl_Obj **)
- TclStackAlloc(interp, numLists * sizeof(Tcl_Obj *));
- for (i = 0; i < numLists; i++) {
- index[i] = 0;
- varcList[i] = 0;
- varvList[i] = NULL;
- vCopyList[i] = NULL;
- argcList[i] = 0;
- argvList[i] = NULL;
- aCopyList[i] = NULL;
- }
+ TclStackAlloc(interp, 2 * numLists * sizeof(Tcl_Obj *));
+ aCopyList = vCopyList + numLists;
+ memset(vCopyList, 0, 2 * numLists * sizeof(Tcl_Obj *));
/*
* Break up the value lists and variable lists into elements.
@@ -1841,13 +1835,9 @@ Tcl_ForeachObjCmd(
Tcl_DecrRefCount(aCopyList[i]);
}
}
- TclStackFree(interp); /* aCopyList */
- TclStackFree(interp); /* argvList */
- TclStackFree(interp); /* argcList */
- TclStackFree(interp); /* vCopyList */
- TclStackFree(interp); /* varvList */
- TclStackFree(interp); /* varcList */
- TclStackFree(interp); /* index */
+ TclStackFree(interp); /* Tcl_Obj * arrays */
+ TclStackFree(interp); /* Tcl_Obj ** arrays */
+ TclStackFree(interp); /* int arrays */
return result;
}