diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-01-30 15:43:34 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-01-30 15:43:34 (GMT) |
commit | 84edc366a514da71f1b7e88a4984ea45cf2b6bc2 (patch) | |
tree | 941a096e0eb398121c62f012a0fe9145d70e657b | |
parent | 6740ac50e9a65342cacd77245cacb8ad443dda00 (diff) | |
download | tcl-84edc366a514da71f1b7e88a4984ea45cf2b6bc2.zip tcl-84edc366a514da71f1b7e88a4984ea45cf2b6bc2.tar.gz tcl-84edc366a514da71f1b7e88a4984ea45cf2b6bc2.tar.bz2 |
* generic/tclCompCmds.c (TclCompileCatchCmd): Added a more efficient
bytecode generator for the case where 'catch' is used without any
variable arguments; don't capture the result just to discard it.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | generic/tclCompCmds.c | 30 |
2 files changed, 40 insertions, 6 deletions
@@ -1,10 +1,16 @@ +2012-01-30 Donal K. Fellows <dkf@users.sf.net> + + * generic/tclCompCmds.c (TclCompileCatchCmd): Added a more efficient + bytecode generator for the case where 'catch' is used without any + variable arguments; don't capture the result just to discard it. + 2012-01-26 Don Porter <dgp@users.sourceforge.net> - * generic/tclCmdAH.c: New internal routine TclJoinPath(). - * generic/tclFCmd.c: Refactor all the *Join*Path* routines - * generic/tclFileName.c: to give them more useful interfaces - * generic/tclInt.h: that are easier to manage getting the - * generic/tclPathObj.c: refcounts right. [Bug 3479689] + * generic/tclCmdAH.c: [Bug 3479689]: New internal routine + * generic/tclFCmd.c: TclJoinPath(). Refactor all the + * generic/tclFileName.c: *Join*Path* routines to give them more + * generic/tclInt.h: useful interfaces that are easier to + * generic/tclPathObj.c: manage getting the refcounts right. 2012-01-26 Don Porter <dgp@users.sourceforge.net> diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 69b44ed..1edb56b 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -390,6 +390,32 @@ TclCompileCatchCmd( * simple: <mark> result */ + if (resultIndex == -1) { + /* + * Special case when neither result nor options are being saved. In + * that case, we can skip quite a bit of the command epilogue; all we + * have to do is drop the result and push the return code (and, of + * course, finish the catch context). + */ + + TclEmitOpcode( INST_POP, envPtr); + PushLiteral(envPtr, "0", 1); + TclEmitInstInt1( INST_JUMP1, 3, envPtr); + envPtr->currStackDepth = savedStackDepth; + ExceptionRangeTarget(envPtr, range, catchOffset); + TclEmitOpcode( INST_PUSH_RETURN_CODE, envPtr); + ExceptionRangeEnds(envPtr, range); + TclEmitOpcode( INST_END_CATCH, envPtr); + + /* + * Stack at this point: + * nonsimple: script <mark> returnCode + * simple: <mark> returnCode + */ + + goto dropScriptAtEnd; + } + /* * Emit the "no errors" epilogue: push "0" (TCL_OK) as the catch * result, and jump around the "error case" code. @@ -467,7 +493,9 @@ TclCompileCatchCmd( TclEmitOpcode( INST_POP, envPtr); } - /* + dropScriptAtEnd: + + /* * Stack is now ?script? result. Get rid of the subst'ed script * if it's hanging arond. */ |