Jim Tcl
Check-in [e4c02883cb]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:defer: fast lookup existence of $jim::defer

This speeds up call frame destruction in the common case that $jim::defer does not exist.

Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e4c02883cbb11faacac642803573c4a10e2e9162
User & Date: steveb@workware.net.au 2017-09-16 05:37:27
Context
2017-09-16
05:37
perf: cache successful Jim_GetEnum() results

When Jim_GetEnum() succeeds, cache the result in the object to speed up subsequent identical calls to Jim_GetEnum()

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 2ff8f28bc3 user: steveb@workware.net.au tags: trunk

05:37
defer: fast lookup existence of $jim::defer

This speeds up call frame destruction in the common case that $jim::defer does not exist.

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: e4c02883cb user: steveb@workware.net.au tags: trunk

2017-09-15
09:17
Implement defer, $jim::defer

Allows commands to run when a proc or interpreter exits.

If the $jim::defer variables exists at proc or interp exit, it is treated as a list of scripts to evaluate (in reverse order).

The [defer] command is a helper to add scripts to $jim::defer

See tests/defer.test

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 027a885518 user: steveb@workware.net.au tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jim.c.

5030
5031
5032
5033
5034
5035
5036







5037
5038
5039
5040

5041
5042
5043
5044
5045
5046
5047
 *
 * retcode is the return code from the current proc.
 *
 * Returns the new return code.
 */
static int JimInvokeDefer(Jim_Interp *interp, int retcode)
{







    Jim_Obj *objPtr = Jim_GetVariableStr(interp, "jim::defer", JIM_NONE);
    int ret = JIM_OK;

    if (objPtr) {

        int i;
        int listLen = Jim_ListLength(interp, objPtr);
        Jim_Obj *resultObjPtr;

        Jim_IncrRefCount(objPtr);

        /* Need to save away the current interp result and







>
>
>
>
>
>
>
|
<


>







5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044

5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
 *
 * retcode is the return code from the current proc.
 *
 * Returns the new return code.
 */
static int JimInvokeDefer(Jim_Interp *interp, int retcode)
{
    Jim_Obj *objPtr;

    /* Fast check for the likely case that the variable doesn't exist */
    if (Jim_FindHashEntry(&interp->framePtr->vars, "jim::defer") == NULL) {
        return retcode;
    }

    objPtr = Jim_GetVariableStr(interp, "jim::defer", JIM_NONE);


    if (objPtr) {
        int ret = JIM_OK;
        int i;
        int listLen = Jim_ListLength(interp, objPtr);
        Jim_Obj *resultObjPtr;

        Jim_IncrRefCount(objPtr);

        /* Need to save away the current interp result and