diff options
author | sebres <sebres@users.sourceforge.net> | 2019-05-16 18:19:25 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2019-05-16 18:19:25 (GMT) |
commit | 1f5c7c693b88225d758e750677764203458dd26a (patch) | |
tree | 63a61cb6276a37fb4b4249ce45ae60aaf6743519 | |
parent | 8af3fb7317d53796f74a0cda158ecbe8e4fa1013 (diff) | |
parent | 2865a8da13749af3807ff9ea42c079f8c6c73133 (diff) | |
download | tcl-1f5c7c693b88225d758e750677764203458dd26a.zip tcl-1f5c7c693b88225d758e750677764203458dd26a.tar.gz tcl-1f5c7c693b88225d758e750677764203458dd26a.tar.bz2 |
merge 8.5
-rw-r--r-- | generic/tclCmdMZ.c | 7 | ||||
-rw-r--r-- | tests/cmdMZ.test | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index e58d026..1358d06 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -4328,6 +4328,7 @@ Tcl_TimeRateObjCmd( }; NRE_callback *rootPtr; ByteCode *codePtr = NULL; + int codeOptimized = 0; for (i = 1; i < objc - 1; i++) { int index; @@ -4519,6 +4520,7 @@ Tcl_TimeRateObjCmd( */ if (codePtr->codeStart[codePtr->numCodeBytes-1] == INST_DONE) { codePtr->codeStart[codePtr->numCodeBytes-1] = INST_CONTINUE; + codeOptimized = 1; } } @@ -4810,6 +4812,11 @@ Tcl_TimeRateObjCmd( done: if (codePtr != NULL) { + if ( codeOptimized + && codePtr->codeStart[codePtr->numCodeBytes-1] == INST_CONTINUE + ) { + codePtr->codeStart[codePtr->numCodeBytes-1] = INST_DONE; + } TclReleaseByteCode(codePtr); } return result; diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index cbccd1c..b574886 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -428,6 +428,12 @@ test cmdMZ-6.10 {Tcl_TimeRateObjCmd: huge overhead cause 0us result} { [expr {[lindex $m1 4] == 1000000}] \ [expr {[lindex $m1 6] <= 0.001}] } {1 1 1 1} +test cmdMZ-6.11 {Tcl_TimeRateObjCmd: done/continue optimization rollback} { + set m1 {set m2 ok} + if 1 $m1 + timerate $m1 1000 10 + if 1 $m1; # if rollback is missing throws an error: invoked "continue" outside of a loop +} ok # The tests for Tcl_WhileObjCmd are in while.test |