mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Optimization: When loading a new page into the cache, avoid redundant memset() calls to zero it. (CVS 6201)
FossilOrigin-Name: 9c0b9f881367871105965d4268e2f2cde7f4d884
This commit is contained in:
17
src/pcache.c
17
src/pcache.c
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file implements that page cache.
|
||||
**
|
||||
** @(#) $Id: pcache.c,v 1.42 2009/01/20 17:06:27 danielk1977 Exp $
|
||||
** @(#) $Id: pcache.c,v 1.43 2009/01/23 16:45:01 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -261,14 +261,21 @@ int sqlite3PcacheFetch(
|
||||
}
|
||||
|
||||
if( pPage ){
|
||||
if( !pPage->pData ){
|
||||
memset(pPage, 0, sizeof(PgHdr) + pCache->szExtra);
|
||||
pPage->pExtra = (void*)&pPage[1];
|
||||
pPage->pData = (void *)&((char *)pPage)[sizeof(PgHdr) + pCache->szExtra];
|
||||
pPage->pCache = pCache;
|
||||
pPage->pgno = pgno;
|
||||
}
|
||||
assert( pPage->pCache==pCache );
|
||||
assert( pPage->pgno==pgno );
|
||||
assert( pPage->pExtra==(void *)&pPage[1] );
|
||||
|
||||
if( 0==pPage->nRef ){
|
||||
pCache->nRef++;
|
||||
}
|
||||
pPage->nRef++;
|
||||
pPage->pData = (void*)&pPage[1];
|
||||
pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage];
|
||||
pPage->pCache = pCache;
|
||||
pPage->pgno = pgno;
|
||||
if( pgno==1 ){
|
||||
pCache->pPage1 = pPage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user