summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2019-05-17 10:40:17 (GMT)
committersebres <sebres@users.sourceforge.net>2019-05-17 10:40:17 (GMT)
commita68f7032b3a1880b9edd85bcf98d5a38e7705067 (patch)
treea4fd5ea3747f4eed60de918c1b4f02bc13242db3 /generic
parent503da2614f2490195b2bd436c44cc52f3678becd (diff)
parent1f5c7c693b88225d758e750677764203458dd26a (diff)
downloadtcl-a68f7032b3a1880b9edd85bcf98d5a38e7705067.zip
tcl-a68f7032b3a1880b9edd85bcf98d5a38e7705067.tar.gz
tcl-a68f7032b3a1880b9edd85bcf98d5a38e7705067.tar.bz2
merge 8.6
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 6792378..7b83370 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4188,6 +4188,7 @@ Tcl_TimeRateObjCmd(
};
NRE_callback *rootPtr;
ByteCode *codePtr = NULL;
+ int codeOptimized = 0;
for (i = 1; i < objc - 1; i++) {
int index;
@@ -4372,6 +4373,15 @@ Tcl_TimeRateObjCmd(
}
codePtr = TclCompileObj(interp, objPtr, NULL, 0);
TclPreserveByteCode(codePtr);
+ /*
+ * Replace last compiled done instruction with continue: it's a part of
+ * iteration, this way evaluation will be more similar to a cycle (also
+ * avoids extra overhead to set result to interp, etc.)
+ */
+ if (codePtr->codeStart[codePtr->numCodeBytes-1] == INST_DONE) {
+ codePtr->codeStart[codePtr->numCodeBytes-1] = INST_CONTINUE;
+ codeOptimized = 1;
+ }
}
/*
@@ -4418,23 +4428,25 @@ Tcl_TimeRateObjCmd(
} else { /* eval */
result = TclEvalObjEx(interp, objPtr, 0, NULL, 0);
}
- if (result != TCL_OK) {
- /*
- * Allow break from measurement cycle (used for conditional
- * stop).
- */
+ /*
+ * Allow break and continue from measurement cycle (used for
+ * conditional stop and flow control of iterations).
+ */
- if (result != TCL_BREAK) {
+ switch (result) {
+ case TCL_OK:
+ break;
+ case TCL_BREAK:
+ /*
+ * Force stop immediately.
+ */
+ threshold = 1;
+ maxcnt = 0;
+ case TCL_CONTINUE:
+ result = TCL_OK;
+ break;
+ default:
goto done;
- }
-
- /*
- * Force stop immediately.
- */
-
- threshold = 1;
- maxcnt = 0;
- result = TCL_OK;
}
/*
@@ -4660,6 +4672,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;