summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-04-04 11:21:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-04-04 11:21:03 (GMT)
commitb4d78562f6e023b1bf1accc8649c1a93b14be8d6 (patch)
tree4ce9a1de9e6cbb1eca994706a5a292b6d0f1377c
parentf34e441fc16a51536c68eead8a87da4aa9306309 (diff)
parentf6c021c559b57cc973581cb328496b13e5f3c952 (diff)
downloadtcl-b4d78562f6e023b1bf1accc8649c1a93b14be8d6.zip
tcl-b4d78562f6e023b1bf1accc8649c1a93b14be8d6.tar.gz
tcl-b4d78562f6e023b1bf1accc8649c1a93b14be8d6.tar.bz2
micro-optimization from drh-micro-optimization branch: Knock perhaps 1% off execution time: guard on TclAsyncReady more efficient when decrementing to zero.
-rw-r--r--generic/tclExecute.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index d4077f5..0e98222 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -35,14 +35,14 @@
#endif
/*
- * A mask (should be 2**n-1) that is used to work out when the bytecode engine
- * should call Tcl_AsyncReady() to see whether there is a signal that needs
- * handling.
+ * A counter that is used to work out when the bytecode engine should call
+ * Tcl_AsyncReady() to see whether there is a signal that needs handling, and
+ * other expensive periodic operations.
*/
-#ifndef ASYNC_CHECK_COUNT_MASK
-# define ASYNC_CHECK_COUNT_MASK 63
-#endif /* !ASYNC_CHECK_COUNT_MASK */
+#ifndef ASYNC_CHECK_COUNT
+# define ASYNC_CHECK_COUNT 64
+#endif /* !ASYNC_CHECK_COUNT */
/*
* Boolean flag indicating whether the Tcl bytecode interpreter has been
@@ -2115,7 +2115,8 @@ TEBCresume(
* sporadically: no special need for speed.
*/
- int instructionCount = 0; /* Counter that is used to work out when to
+ int instructionCount = ASYNC_CHECK_COUNT;
+ /* Counter that is used to work out when to
* call Tcl_AsyncReady() */
const char *curInstName;
#ifdef TCL_COMPILE_DEBUG
@@ -2314,10 +2315,11 @@ TEBCresume(
/*
* Check for asynchronous handlers [Bug 746722]; we do the check every
- * ASYNC_CHECK_COUNT_MASK instruction, of the form (2**n-1).
+ * ASYNC_CHECK_COUNT instructions.
*/
- if ((instructionCount++ & ASYNC_CHECK_COUNT_MASK) == 0) {
+ if (!(--instructionCount)) {
+ instructionCount = ASYNC_CHECK_COUNT;
DECACHE_STACK_INFO();
if (TclAsyncReady(iPtr)) {
result = Tcl_AsyncInvoke(interp, result);