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 | 1466ca42b6b8408a32fc9424849d044f1b8f3930 (patch) | |
| tree | e02a27283e2c78b039939d410c9a0a89895ae4db | |
| parent | ec6d997075e31fda5243fd781c4046c646d2f127 (diff) | |
| download | tcl-1466ca42b6b8408a32fc9424849d044f1b8f3930.zip tcl-1466ca42b6b8408a32fc9424849d044f1b8f3930.tar.gz tcl-1466ca42b6b8408a32fc9424849d044f1b8f3930.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; |
