diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2015-10-23 21:52:10 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2015-10-23 21:52:10 (GMT) |
commit | f6c021c559b57cc973581cb328496b13e5f3c952 (patch) | |
tree | ace3bf8d6d534ab331a23f9052e97ec9d6536a5a | |
parent | ca9cf2ba57b9245e21d8bd908ffdbea32ed3d7cd (diff) | |
download | tcl-f6c021c559b57cc973581cb328496b13e5f3c952.zip tcl-f6c021c559b57cc973581cb328496b13e5f3c952.tar.gz tcl-f6c021c559b57cc973581cb328496b13e5f3c952.tar.bz2 |
Knock perhaps 1% off execution time: guard on TclAsyncReady more efficient when decrementing to zero.
-rw-r--r-- | generic/tclExecute.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index b10af65..f6dfc46 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -34,14 +34,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 @@ -2116,7 +2116,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 @@ -2315,10 +2316,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); |