1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Size reduction and performance optimization in sqlite3WalFindFrame().

FossilOrigin-Name: 1a8c2e54375ee2cf73773b798fed0ae07b42f5e068fddc513c093de5c1f46615
This commit is contained in:
drh
2022-07-04 15:14:25 +00:00
parent 16316f1b68
commit 3325a5c497
3 changed files with 12 additions and 14 deletions

View File

@@ -3138,20 +3138,17 @@ int sqlite3WalFindFrame(
u32 *piRead /* OUT: Frame number (or zero) */
){
u32 iRead = 0; /* If !=0, WAL frame to return data from */
u32 iLast = pWal->hdr.mxFrame; /* Last page in WAL for this reader */
u32 iLast; /* Last page in WAL for this reader */
int iHash; /* Used to loop through N hash tables */
int iMinHash;
/* This routine is only be called from within a read transaction. */
assert( pWal->readLock>=0 || pWal->lockError );
/* If the "last page" field of the wal-index header snapshot is 0, then
** no data will be read from the wal under any circumstances. Return early
** in this case as an optimization. Likewise, if pWal->readLock==0,
** then the WAL is ignored by the reader so return early, as if the
** WAL were empty.
/* if pWal->readLock==0, then the WAL is ignored by the reader
** so return early, as if the WAL were empty.
*/
if( iLast==0 || (pWal->readLock==0 && pWal->bShmUnreliable==0) ){
if( pWal->readLock==0 && pWal->bShmUnreliable==0 ){
*piRead = 0;
return SQLITE_OK;
}
@@ -3182,6 +3179,7 @@ int sqlite3WalFindFrame(
** table after the current read-transaction had started.
*/
iMinHash = walFramePage(pWal->minFrame);
iLast = pWal->hdr.mxFrame;
for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
WalHashLoc sLoc; /* Hash table location */
int iKey; /* Hash slot index */