summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-10-18 21:16:17 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-10-18 21:16:17 (GMT)
commita1fe345fbfa47cb85f28246a1569fce99cd93712 (patch)
tree8f71c493b644c24cc747d7423e384310de446708
parent9fd8a3e5b180bb328c6c676605cd76c7cce7c751 (diff)
downloadtcl-a1fe345fbfa47cb85f28246a1569fce99cd93712.zip
tcl-a1fe345fbfa47cb85f28246a1569fce99cd93712.tar.gz
tcl-a1fe345fbfa47cb85f28246a1569fce99cd93712.tar.bz2
* generic/tclResult.c (TclMergeReturnOptions): Make sure any -code
values get pulled out of the dictionary, even if they are integer valued. * generic/tclCompCmds.c (TclCompileReturnCmd): Added code to more optimally compile [return -level 0 $x] to "push $x". [RFE 1794073]
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclCompCmds.c10
-rw-r--r--generic/tclResult.c4
3 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0da02e8..3d23ac2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,13 @@
2007-10-18 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclResult.c (TclMergeReturnOptions): Make sure any -code
+ values get pulled out of the dictionary, even if they are integer
+ valued.
+
+ * generic/tclCompCmds.c (TclCompileReturnCmd): Added code to
+ more optimally compile [return -level 0 $x] to "push $x". [RFE 1794073]
+
* compat/tmpnam.c (removed): The routine tmpnam() is no longer
* unix/Makefile.in: called by Tcl source code. Remove autogoo
* unix/configure.in: the supplied a replacement version on
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 5c5831b..99cb133 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.120 2007/09/25 20:27:17 dkf Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.121 2007/10/18 21:16:18 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.
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 64be014..ed2a214 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclResult.c,v 1.38 2007/09/07 15:51:26 dgp Exp $
+ * RCS: @(#) $Id: tclResult.c,v 1.39 2007/10/18 21:16:18 dgp Exp $
*/
#include "tclInt.h"
@@ -1352,6 +1352,8 @@ TclMergeReturnOptions(
"continue, or an integer", NULL);
goto error;
}
+ }
+ if (valuePtr != NULL) {
Tcl_DictObjRemove(NULL, returnOpts, keys[KEY_CODE]);
}