From 53000d1f31d12f8b3e1f7554d2072bb7f141c254 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 6 Jul 2019 16:30:51 +0000 Subject: [PATCH] Make cacheAgeEntries() do a more consistent amount of work per frame git-svn-id: https://svn.eduke32.com/eduke32@7763 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/cache1d.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/build/src/cache1d.cpp b/source/build/src/cache1d.cpp index 669d01933..7d78a87c6 100644 --- a/source/build/src/cache1d.cpp +++ b/source/build/src/cache1d.cpp @@ -289,21 +289,23 @@ void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, char *newlockptr) void cacheAgeEntries(void) { #ifndef DEBUG_ALLOCACHE_AS_MALLOC - static int32_t agecount; + static int agecount; if (agecount >= cacnum) agecount = cacnum-1; - native_t cnt = (cacnum>>4); + int cnt = min(MAXCACHEOBJECTS >> 5, cacnum-1); - if (agecount < 0 || !cnt) - return; - - for (; cnt>=0; cnt--) + while(cnt--) { // If we have pointer to lock char and it's in [2 .. 199], decrease. - if (cac[agecount].lock && (((*cac[agecount].lock)-2)&255) < 198) - (*cac[agecount].lock)--; + if (cac[agecount].lock) + { + if ((((*cac[agecount].lock)-2)&255) < 198) + (*cac[agecount].lock)--; + else if (*cac[agecount].lock >= 200) + cnt++; + } if (--agecount < 0) agecount = cacnum-1;