aboutsummaryrefslogtreecommitdiff
path: root/jim.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-06-05 20:41:41 +1000
committerSteve Bennett <steveb@workware.net.au>2020-06-05 21:48:01 +1000
commitcdfa4637afe510fad7140d03b154bf30b16f8f9c (patch)
treee0d3c57e587d74ef9703b529809ddbfae5729f86 /jim.h
parent5d44077dc5e785c490707f57a420fb92ff99015f (diff)
downloadjimtcl-cdfa4637afe510fad7140d03b154bf30b16f8f9c.zip
jimtcl-cdfa4637afe510fad7140d03b154bf30b16f8f9c.tar.gz
jimtcl-cdfa4637afe510fad7140d03b154bf30b16f8f9c.tar.bz2
core: improve performance through negative command caching
Instead of incrementing the proc epoch on every command removal and some command creation, cache previous deleted commands (empty structure only). Periodically increment the proc epoch and invalide all cached commands. This is especially a win when creating short lived commands. e.g. proc a {} { local proc b {} { # do something } # now b is removed } Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.h')
-rw-r--r--jim.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/jim.h b/jim.h
index 6e9f9b3..ad66b16 100644
--- a/jim.h
+++ b/jim.h
@@ -526,6 +526,7 @@ typedef struct Jim_Interp {
'ID' field contained in the Jim_CallFrame
structure. */
int local; /* If 'local' is in effect, newly defined procs keep a reference to the old defn */
+ int quitting; /* Set to 1 during Jim_FreeInterp() */
Jim_Obj *liveList; /* Linked list of all the live objects. */
Jim_Obj *freeList; /* Linked list of all the unused objects. */
Jim_Obj *currentScriptObj; /* Script currently in execution. */
@@ -551,6 +552,8 @@ typedef struct Jim_Interp {
a command. It is set to what the user specified
via Jim_CreateCommand(). */
+ Jim_Cmd *oldCmdCache; /* commands that have been deleted, but may still be cached */
+ int oldCmdCacheSize; /* Number of delete commands */
struct Jim_CallFrame *freeFramesList; /* list of CallFrame structures. */
struct Jim_HashTable assocData; /* per-interp storage for use by packages */
Jim_PrngState *prngState; /* per interpreter Random Number Gen. state. */
@@ -562,7 +565,6 @@ typedef struct Jim_Interp {
* At some point may be a real function doing more work.
* The proc epoch is used in order to know when a command lookup
* cached can no longer considered valid. */
-#define Jim_InterpIncrProcEpoch(i) (i)->procEpoch++
#define Jim_SetResultString(i,s,l) Jim_SetResult(i, Jim_NewStringObj(i,s,l))
#define Jim_SetResultInt(i,intval) Jim_SetResult(i, Jim_NewIntObj(i,intval))
/* Note: Using trueObj and falseObj here makes some things slower...*/