diff options
author | msofer <msofer@noemail.net> | 2002-08-23 21:07:01 (GMT) |
---|---|---|
committer | msofer <msofer@noemail.net> | 2002-08-23 21:07:01 (GMT) |
commit | 19cf22566ac0b46fda9405abede1f7c15816b46d (patch) | |
tree | c3e7856d98ab777fe15547318de2a6c04ba8f3eb /generic/tclThreadAlloc.c | |
parent | 72f8aa62df57cd57979a49fb97ada1c4a9f77d4d (diff) | |
download | tcl-19cf22566ac0b46fda9405abede1f7c15816b46d.zip tcl-19cf22566ac0b46fda9405abede1f7c15816b46d.tar.gz tcl-19cf22566ac0b46fda9405abede1f7c15816b46d.tar.bz2 |
* generic/tclThreadAlloc.c (USE_THREAD_ALLOC): moving objects
between caches as a block, instead of one-by-one.
FossilOrigin-Name: 919a9e1ad05e57dc590c3deaf050f9d5ee1599d8
Diffstat (limited to 'generic/tclThreadAlloc.c')
-rwxr-xr-x | generic/tclThreadAlloc.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c index 89bc9df..4d93305 100755 --- a/generic/tclThreadAlloc.c +++ b/generic/tclThreadAlloc.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclThreadAlloc.c,v 1.2 2002/05/29 00:18:29 hobbs Exp $ */ + * RCS: @(#) $Id: tclThreadAlloc.c,v 1.3 2002/08/23 21:07:04 msofer Exp $ */ #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) @@ -570,13 +570,13 @@ TclThreadFreeObj(Tcl_Obj *objPtr) objPtr->internalRep.otherValuePtr = cachePtr->firstObjPtr; cachePtr->firstObjPtr = objPtr; + ++cachePtr->nobjs; /* * If the number of free objects has exceeded the high * water mark, move some blocks to the shared list. */ - ++cachePtr->nobjs; if (cachePtr->nobjs > NOBJHIGH) { Tcl_MutexLock(objLockPtr); MoveObjs(cachePtr, sharedPtr, NOBJALLOC); @@ -655,16 +655,30 @@ Tcl_GetMemoryInfo(Tcl_DString *dsPtr) static void MoveObjs(Cache *fromPtr, Cache *toPtr, int nmove) { - register Tcl_Obj *objPtr; + register Tcl_Obj *objPtr = fromPtr->firstObjPtr; + Tcl_Obj *fromFirstObjPtr = objPtr; toPtr->nobjs += nmove; fromPtr->nobjs -= nmove; - while (--nmove >= 0) { - objPtr = fromPtr->firstObjPtr; - fromPtr->firstObjPtr = objPtr->internalRep.otherValuePtr; - objPtr->internalRep.otherValuePtr = toPtr->firstObjPtr; - toPtr->firstObjPtr = objPtr; + + /* + * Find the last object to be moved; set the next one + * (the first one not to be moved) as the first object + * in the 'from' cache. + */ + + while (--nmove) { + objPtr = objPtr->internalRep.otherValuePtr; } + fromPtr->firstObjPtr = objPtr->internalRep.otherValuePtr; + + /* + * Move all objects as a block - they are already linked to + * each other, we just have to update the first and last. + */ + + objPtr->internalRep.otherValuePtr = toPtr->firstObjPtr; + toPtr->firstObjPtr = fromFirstObjPtr; } |