diff options
| author | donal.k.fellows@manchester.ac.uk <dkf> | 2012-07-31 12:19:34 (GMT) |
|---|---|---|
| committer | donal.k.fellows@manchester.ac.uk <dkf> | 2012-07-31 12:19:34 (GMT) |
| commit | 1cd5f001bed6f6471e9afd726e15b21686d30032 (patch) | |
| tree | e02a27283e2c78b039939d410c9a0a89895ae4db | |
| parent | 87aeb88b8737f472fdc39a0a17465431099c9b1e (diff) | |
| download | tcl-1cd5f001bed6f6471e9afd726e15b21686d30032.zip tcl-1cd5f001bed6f6471e9afd726e15b21686d30032.tar.gz tcl-1cd5f001bed6f6471e9afd726e15b21686d30032.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; |
