diff options
author | dgp <dgp@users.sourceforge.net> | 2016-07-13 19:06:22 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-07-13 19:06:22 (GMT) |
commit | ab2a78be642be26075e2998347d71359a6b3c500 (patch) | |
tree | 30640bd9d81f1c2ebb578d5aae95f27240b26854 /generic/tclIndexObj.c | |
parent | 800148e0621ab1e28457aa915d37dd5c36c1ba77 (diff) | |
download | tcl-ab2a78be642be26075e2998347d71359a6b3c500.zip tcl-ab2a78be642be26075e2998347d71359a6b3c500.tar.gz tcl-ab2a78be642be26075e2998347d71359a6b3c500.tar.bz2 |
New private flag value INDEX_TEMP_TABLE.
Used to signal to Tcl_GetIndexFromObj*() routines that the table in which
lookups are done has a fleeting existence. Thus there is no value in caching
any results, since the cache can never be useful. Improvement over existing
hackery where cache is stored and then freed to avoid bogus results.
Likely candidate to eventually push to the public interface.
Diffstat (limited to 'generic/tclIndexObj.c')
-rw-r--r-- | generic/tclIndexObj.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 2281d22..c6873af 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -114,6 +114,7 @@ Tcl_GetIndexFromObj( int flags, /* 0 or TCL_EXACT */ int *indexPtr) /* Place to store resulting integer index. */ { + if (!(flags & INDEX_TEMP_TABLE)) { /* * See if there is a valid cached result from a previous lookup (doing the @@ -135,6 +136,7 @@ Tcl_GetIndexFromObj( return TCL_OK; } } + } return Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, sizeof(char *), msg, flags, indexPtr); } @@ -211,13 +213,8 @@ GetIndexFromObjList( tablePtr[objc] = NULL; result = Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, - sizeof(char *), msg, flags, indexPtr); - - /* - * The internal rep must be cleared since tablePtr will go away. - */ + sizeof(char *), msg, flags | INDEX_TEMP_TABLE, indexPtr); - TclFreeIntRep(objPtr); ckfree(tablePtr); return result; @@ -279,6 +276,7 @@ Tcl_GetIndexFromObjStruct( * See if there is a valid cached result from a previous lookup. */ + if (!(flags & INDEX_TEMP_TABLE)) { if (objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.twoPtrValue.ptr1; if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { @@ -286,6 +284,7 @@ Tcl_GetIndexFromObjStruct( return TCL_OK; } } + } /* * Lookup the value of the object in the table. Accept unique @@ -340,6 +339,7 @@ Tcl_GetIndexFromObjStruct( * operation. */ + if (!(flags & INDEX_TEMP_TABLE)) { if (objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.twoPtrValue.ptr1; } else { @@ -351,6 +351,7 @@ Tcl_GetIndexFromObjStruct( indexRep->tablePtr = (void *) tablePtr; indexRep->offset = offset; indexRep->index = index; + } *indexPtr = index; return TCL_OK; |