summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmds.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-10-19 14:29:59 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-10-19 14:29:59 (GMT)
commit8954280ce7849f9bd776d6e1d398a4a937960b32 (patch)
tree3e9777aef740ddb43780593de9bd08eb8e91eedf /generic/tclCompCmds.c
parent9e421a80153ea4778e23bfc5ebc25a25861fb08e (diff)
downloadtcl-8954280ce7849f9bd776d6e1d398a4a937960b32.zip
tcl-8954280ce7849f9bd776d6e1d398a4a937960b32.tar.gz
tcl-8954280ce7849f9bd776d6e1d398a4a937960b32.tar.bz2
merge updates from HEAD
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r--generic/tclCompCmds.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index ee5a8cd..6468ea9 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.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: tclCompCmds.c,v 1.109.2.8 2007/10/02 20:11:54 dgp Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.109.2.9 2007/10/19 14:30:01 dgp Exp $
*/
#include "tclInt.h"
@@ -3088,7 +3088,7 @@ TclCompileReturnCmd(
* General syntax: [return ?-option value ...? ?result?]
* An even number of words means an explicit result argument is present.
*/
- int level, code, objc, status = TCL_OK;
+ int level, code, objc, size, status = TCL_OK;
int numWords = parsePtr->numWords;
int explicitResult = (0 == (numWords % 2));
int numOptionWords = numWords - 1 - explicitResult;
@@ -3208,6 +3208,12 @@ TclCompileReturnCmd(
}
}
+ /* Optimize [return -level 0 $x]. */
+ Tcl_DictObjSize(NULL, returnOpts, &size);
+ if (size == 0 && level == 0 && code == TCL_OK) {
+ return TCL_OK;
+ }
+
/*
* Could not use the optimization, so we push the return options dict, and
* emit the INST_RETURN_IMM instruction with code and level as operands.