summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2002-08-26 13:05:55 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2002-08-26 13:05:55 (GMT)
commit283f4b6204dfa73280a57969b67b4151175142b0 (patch)
tree7403a362f14677a3050baff9e093e8b5c1c1eb82 /generic
parentd4474d5baddde165c995c7716e6e0604788366a8 (diff)
downloadtcl-283f4b6204dfa73280a57969b67b4151175142b0.zip
tcl-283f4b6204dfa73280a57969b67b4151175142b0.tar.gz
tcl-283f4b6204dfa73280a57969b67b4151175142b0.tar.bz2
* generic/tclThreadAlloc.c: small optimisation, reducing the
new allocator's overhead.
Diffstat (limited to 'generic')
-rwxr-xr-xgeneric/tclThreadAlloc.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c
index 4d93305..8f702f4 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.3 2002/08/23 21:07:04 msofer Exp $ */
+ * RCS: @(#) $Id: tclThreadAlloc.c,v 1.4 2002/08/26 13:05:56 msofer Exp $ */
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
@@ -42,6 +42,7 @@ extern void TclpSetAllocCache(void *);
* The following define the number of Tcl_Obj's to allocate/move
* at a time and the high water mark to prune a per-thread cache.
* On a 32 bit system, sizeof(Tcl_Obj) = 24 so 800 * 24 = ~16k.
+ *
*/
#define NOBJALLOC 800
@@ -302,10 +303,14 @@ TclFreeAllocCache(void *arg)
char *
TclpAlloc(unsigned int reqsize)
{
- Cache *cachePtr = GetCache();
+ Cache *cachePtr = TclpGetAllocCache();
Block *blockPtr;
register int bucket;
size_t size;
+
+ if (cachePtr == NULL) {
+ cachePtr = GetCache();
+ }
/*
* Increment the requested size to include room for
@@ -366,9 +371,13 @@ void
TclpFree(char *ptr)
{
if (ptr != NULL) {
- Cache *cachePtr = GetCache();
+ Cache *cachePtr = TclpGetAllocCache();
Block *blockPtr;
int bucket;
+
+ if (cachePtr == NULL) {
+ cachePtr = GetCache();
+ }
/*
* Get the block back from the user pointer and
@@ -417,7 +426,7 @@ TclpFree(char *ptr)
char *
TclpRealloc(char *ptr, unsigned int reqsize)
{
- Cache *cachePtr = GetCache();
+ Cache *cachePtr = TclpGetAllocCache();
Block *blockPtr;
void *new;
size_t size, min;
@@ -427,6 +436,10 @@ TclpRealloc(char *ptr, unsigned int reqsize)
return TclpAlloc(reqsize);
}
+ if (cachePtr == NULL) {
+ cachePtr = GetCache();
+ }
+
/*
* If the block is not a system block and fits in place,
* simply return the existing pointer. Otherwise, if the block
@@ -497,11 +510,15 @@ TclpRealloc(char *ptr, unsigned int reqsize)
Tcl_Obj *
TclThreadAllocObj(void)
{
- register Cache *cachePtr = GetCache();
+ register Cache *cachePtr = TclpGetAllocCache();
register int nmove;
register Tcl_Obj *objPtr;
Tcl_Obj *newObjsPtr;
+ if (cachePtr == NULL) {
+ cachePtr = GetCache();
+ }
+
/*
* Get this thread's obj list structure and move
* or allocate new objs if necessary.
@@ -562,7 +579,11 @@ TclThreadAllocObj(void)
void
TclThreadFreeObj(Tcl_Obj *objPtr)
{
- Cache *cachePtr = GetCache();
+ Cache *cachePtr = TclpGetAllocCache();
+
+ if (cachePtr == NULL) {
+ cachePtr = GetCache();
+ }
/*
* Get this thread's list and push on the free Tcl_Obj.