|
From: Andre R. <and...@us...> - 2004-11-20 23:25:22
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20556/Common/source Modified Files: Tag: New_Tables_Experiment-branch arraylist.c Log Message: Simplified the code for recycling lists. Right now, we always allocate new lists at the default size, so we should only keep lists of that size around instead of disposing. Otherwise, we would end up using memory for lists waiting to be recycled that never will be recycled. Index: arraylist.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/Attic/arraylist.c,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** arraylist.c 20 Nov 2004 18:53:20 -0000 1.1.2.6 --- arraylist.c 20 Nov 2004 23:24:44 -0000 1.1.2.7 *************** *** 94,105 **** #ifdef flrecyclefreelists ! #define maxfreelistlogsize 14 ! ! static hdllist hfreelists[maxfreelistlogsize]; #ifdef fldebug ! static int hdebuglistsallocated[maxfreelistlogsize]; ! static int hdebuglistsrecycled[maxfreelistlogsize]; #endif --- 94,103 ---- #ifdef flrecyclefreelists ! static hdllist hfreeliststack = nil; #ifdef fldebug ! static int ctdebuglistsallocated = 0; ! static int ctdebuglistsrecycled = 0; #endif *************** *** 348,358 **** #ifdef flrecyclefreelists ! if (logsize < maxfreelistlogsize) { ! if ((h = hfreelists[logsize]) != nil) { assert (gethandlesize ((Handle) h) == sizeof (tylist) + sizeof (Handle) * (1 << logsize)); ! hfreelists[logsize] = (hdllist) (**h).item[0]; /*pop from stack*/ initlist (h, logsize); --- 346,356 ---- #ifdef flrecyclefreelists ! if (logsize == LIST_INITIAL_LOGSIZE) { ! if ((h = hfreeliststack) != nil) { assert (gethandlesize ((Handle) h) == sizeof (tylist) + sizeof (Handle) * (1 << logsize)); ! hfreeliststack = (hdllist) (**h).item[0]; /*pop from stack*/ initlist (h, logsize); *************** *** 361,365 **** #ifdef fldebug ! hdebuglistsrecycled[logsize]++; #endif --- 359,363 ---- #ifdef fldebug ! ctdebuglistsrecycled++; #endif *************** *** 368,372 **** #ifdef fldebug ! hdebuglistsallocated[logsize]++; #endif } --- 366,370 ---- #ifdef fldebug ! ctdebuglistsallocated++; #endif } *************** *** 407,415 **** assert (gethandlesize ((Handle) hlist) == (sizeof (tylist) + sizeof (Handle) * (1 << logsize))); ! if (logsize < maxfreelistlogsize) { ! (**hlist).item[0] = (Handle) hfreelists[logsize]; ! hfreelists[logsize] = hlist; return; --- 405,413 ---- assert (gethandlesize ((Handle) hlist) == (sizeof (tylist) + sizeof (Handle) * (1 << logsize))); ! if (logsize == LIST_INITIAL_LOGSIZE) { ! (**hlist).item[0] = (Handle) hfreeliststack; ! hfreeliststack = hlist; return; *************** *** 427,442 **** hdllist h; ! long k; ! ! for (k = 0; k < maxfreelistlogsize; k++) { ! for (h = (hdllist) hfreelists[k]; h != nil; h = (hdllist) hfreelists[k]) { ! ! hfreelists[k] = (hdllist) (**h).item[0]; ! *ctbytesneeded -= gethandlesize ((Handle) h); ! ! disposehandle ((Handle) h); ! } /*for*/ } /*for*/ --- 425,436 ---- hdllist h; ! ! for (h = hfreeliststack; h != nil; h = hfreeliststack) { ! ! hfreeliststack = (hdllist) (**h).item[0]; ! *ctbytesneeded -= gethandlesize ((Handle) h); ! disposehandle ((Handle) h); } /*for*/ |