File tree Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -602,30 +602,15 @@ static u16 ceshimSwitchPageMap(ceshim_file *p, sqlite_int64 iUppOfst){
602602 ceshim_header * header = & pInfo -> ceshimHeader ;
603603 u16 ix = 0 ;
604604
605- // find page map
606- #if 1
605+ /*
606+ Calculate map index based on upper pager offset.
607+ Check last entry first as an optimization in case we are writing.
608+ Perhaps we can do this check only when we are writing, skip for read-only.
609+ */
607610 ix = iUppOfst >= (pInfo -> nBytesPerPgMap * header -> mmTblCurrCnt )
608611 ? header -> mmTblCurrCnt - 1
609612 : (u16 )(iUppOfst / pInfo -> nBytesPerPgMap );
610613 if ( ix < header -> mmTblCurrCnt ) rc = SQLITE_OK ;
611- #else
612- // check last entry first (edge case)
613- if ( iUppOfst >= pInfo -> mmTbl [header -> mmTblCurrCnt - 1 ].uppOfst ){
614- ix = header -> mmTblCurrCnt - 1 ;
615- rc = SQLITE_OK ;
616- }else {
617- for (int i = 0 ; i < header -> mmTblCurrCnt - 1 ; i ++ ){
618- if (
619- pInfo -> mmTbl [i ].uppOfst <= iUppOfst
620- && iUppOfst < pInfo -> mmTbl [i + 1 ].uppOfst
621- ){
622- ix = i ;
623- rc = SQLITE_OK ;
624- break ;
625- }
626- }
627- }
628- #endif
629614
630615 // switch
631616 if ( rc == SQLITE_OK && ix != pInfo -> mmTblCurrIx ){
You can’t perform that action at this time.
0 commit comments