diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-07-31 12:19:34 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-07-31 12:19:34 (GMT) |
commit | e9c4df38ad5b45c6e4ee30e7f1d9ac343d0e6610 (patch) | |
tree | e02a27283e2c78b039939d410c9a0a89895ae4db | |
parent | 8beec4c8178ef562683747377c7a2a7967ae822b (diff) | |
download | tcl-e9c4df38ad5b45c6e4ee30e7f1d9ac343d0e6610.zip tcl-e9c4df38ad5b45c6e4ee30e7f1d9ac343d0e6610.tar.gz tcl-e9c4df38ad5b45c6e4ee30e7f1d9ac343d0e6610.tar.bz2 |
import small refactoring from TclOO package codebase
-rw-r--r-- | generic/tclOO.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c index 821befd..df7d49d 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -81,6 +81,7 @@ static void ObjectRenamedTrace(ClientData clientData, Tcl_Interp *interp, const char *oldName, const char *newName, int flags); static void ReleaseClassContents(Tcl_Interp *interp,Object *oPtr); +static inline void SquelchCachedName(Object *oPtr); static void SquelchedNsFirst(ClientData clientData); static int PublicObjectCmd(ClientData clientData, @@ -704,6 +705,27 @@ AllocObject( /* * ---------------------------------------------------------------------- * + * SquelchCachedName -- + * + * Encapsulates how to throw away a cached object name. Called from + * object rename traces and at object destruction. + * + * ---------------------------------------------------------------------- + */ + +static inline void +SquelchCachedName( + Object *oPtr) +{ + if (oPtr->cachedNameObj) { + Tcl_DecrRefCount(oPtr->cachedNameObj); + oPtr->cachedNameObj = NULL; + } +} + +/* + * ---------------------------------------------------------------------- + * * MyDeleted -- * * This callback is triggered when the object's [my] command is deleted @@ -778,10 +800,7 @@ ObjectRenamedTrace( */ if (flags & TCL_TRACE_RENAME) { - if (oPtr->cachedNameObj) { - TclDecrRefCount(oPtr->cachedNameObj); - oPtr->cachedNameObj = NULL; - } + SquelchCachedName(oPtr); return; } @@ -1138,10 +1157,7 @@ ObjectNamespaceDeleted( TclOODeleteChainCache(oPtr->chainCache); } - if (oPtr->cachedNameObj) { - TclDecrRefCount(oPtr->cachedNameObj); - oPtr->cachedNameObj = NULL; - } + SquelchCachedName(oPtr); if (oPtr->metadataPtr != NULL) { Tcl_ObjectMetadataType *metadataTypePtr; |