diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2002-08-23 21:07:01 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2002-08-23 21:07:01 (GMT) |
commit | c5d82383792e0299e86439c844793d9d726af8d4 (patch) | |
tree | c3e7856d98ab777fe15547318de2a6c04ba8f3eb /generic | |
parent | 0e4ac702223faf7f961266d9cc0b49495be28156 (diff) | |
download | tcl-c5d82383792e0299e86439c844793d9d726af8d4.zip tcl-c5d82383792e0299e86439c844793d9d726af8d4.tar.gz tcl-c5d82383792e0299e86439c844793d9d726af8d4.tar.bz2 |
* generic/tclThreadAlloc.c (USE_THREAD_ALLOC): moving objects
between caches as a block, instead of one-by-one.
Diffstat (limited to 'generic')
-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; } |