Performance optimization in the memsys5 memory allocator.

FossilOrigin-Name: 949133231f8f751aa86518d0d3f6f03d7827fec085bfef3929fa3d57369d0216
This commit is contained in:
drh
2022-03-28 13:22:54 +00:00
parent be341502db
commit f5a8386c32
3 changed files with 14 additions and 9 deletions
+7 -2
View File
@@ -420,8 +420,13 @@ static void *memsys5Realloc(void *pPrior, int nBytes){
*/
static int memsys5Roundup(int n){
int iFullSz;
if( n > 0x40000000 ) return 0;
for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);
if( n<=mem5.szAtom*2 ){
if( n<=mem5.szAtom ) return mem5.szAtom;
return mem5.szAtom*2;
}
if( n>0x40000000 ) return 0;
for(iFullSz=mem5.szAtom*8; iFullSz<n; iFullSz *= 4);
if( (iFullSz/2)>=n ) return iFullSz/2;
return iFullSz;
}