ucb/source/cacher/cachedcontentresultset.cxx | 118 +++++++++++++-------------- 1 file changed, 58 insertions(+), 60 deletions(-)
New commits: commit 9a2bcf52fb3287f0c0f3199ab46b4044a992884d Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Aug 6 09:11:02 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Aug 6 12:48:49 2025 +0200 swap the if/else order put the immediate return first, no logic change intended. Drop stray ; at the of method. Change-Id: Ifad2c2c25bfb3237710920dd945abcfeca01f655 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188995 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx index 9fa929cdf343..9458e8eb09fc 100644 --- a/ucb/source/cacher/cachedcontentresultset.cxx +++ b/ucb/source/cacher/cachedcontentresultset.cxx @@ -683,83 +683,81 @@ bool CachedContentResultSet rGuard.unlock(); - if( bAfterLastApplied || nLastAppliedPos != nRow ) + if (!bAfterLastApplied && nLastAppliedPos == nRow) + return true; + + if( nForwardOnly == 1 ) { - if( nForwardOnly == 1 ) + if( bAfterLastApplied || bAfterLast || !nRow || nRow < nLastAppliedPos ) + throw SQLException(); + + sal_Int32 nN = nRow - nLastAppliedPos; + sal_Int32 nM; + for( nM = 0; nN--; nM++ ) { - if( bAfterLastApplied || bAfterLast || !nRow || nRow < nLastAppliedPos ) - throw SQLException(); + if( !m_xResultSetOrigin->next() ) + break; + } - sal_Int32 nN = nRow - nLastAppliedPos; - sal_Int32 nM; - for( nM = 0; nN--; nM++ ) - { - if( !m_xResultSetOrigin->next() ) - break; - } + rGuard.lock(); + m_nLastAppliedPos += nM; + m_bAfterLastApplied = nRow != m_nLastAppliedPos; + return nRow == m_nLastAppliedPos; + } - rGuard.lock(); - m_nLastAppliedPos += nM; - m_bAfterLastApplied = nRow != m_nLastAppliedPos; - return nRow == m_nLastAppliedPos; - } + if( !nRow ) //absolute( 0 ) will throw exception + { + m_xResultSetOrigin->beforeFirst(); - if( !nRow ) //absolute( 0 ) will throw exception + rGuard.lock(); + m_nLastAppliedPos = 0; + m_bAfterLastApplied = false; + return false; + } + try + { + //move absolute, if !nLastAppliedPos + //because move relative would throw exception + if( !nLastAppliedPos || bAfterLast || bAfterLastApplied ) { - m_xResultSetOrigin->beforeFirst(); + bool bValid = m_xResultSetOrigin->absolute( nRow ); rGuard.lock(); - m_nLastAppliedPos = 0; - m_bAfterLastApplied = false; - return false; + m_nLastAppliedPos = nRow; + m_bAfterLastApplied = !bValid; + return bValid; } - try + else { - //move absolute, if !nLastAppliedPos - //because move relative would throw exception - if( !nLastAppliedPos || bAfterLast || bAfterLastApplied ) - { - bool bValid = m_xResultSetOrigin->absolute( nRow ); - - rGuard.lock(); - m_nLastAppliedPos = nRow; - m_bAfterLastApplied = !bValid; - return bValid; - } - else - { - bool bValid = m_xResultSetOrigin->relative( nRow - nLastAppliedPos ); + bool bValid = m_xResultSetOrigin->relative( nRow - nLastAppliedPos ); - rGuard.lock(); - m_nLastAppliedPos += ( nRow - nLastAppliedPos ); - m_bAfterLastApplied = !bValid; - return bValid; - } + rGuard.lock(); + m_nLastAppliedPos += ( nRow - nLastAppliedPos ); + m_bAfterLastApplied = !bValid; + return bValid; } - catch (const SQLException&) + } + catch (const SQLException&) + { + rGuard.lock(); + if( !bAfterLastApplied && !bAfterLast && nRow > nLastAppliedPos && impl_isForwardOnly(rGuard) ) { - rGuard.lock(); - if( !bAfterLastApplied && !bAfterLast && nRow > nLastAppliedPos && impl_isForwardOnly(rGuard) ) + sal_Int32 nN = nRow - nLastAppliedPos; + sal_Int32 nM; + for( nM = 0; nN--; nM++ ) { - sal_Int32 nN = nRow - nLastAppliedPos; - sal_Int32 nM; - for( nM = 0; nN--; nM++ ) - { - if( !m_xResultSetOrigin->next() ) - break; - } - - m_nLastAppliedPos += nM; - m_bAfterLastApplied = nRow != m_nLastAppliedPos; + if( !m_xResultSetOrigin->next() ) + break; } - else - throw; - return nRow == m_nLastAppliedPos; + + m_nLastAppliedPos += nM; + m_bAfterLastApplied = nRow != m_nLastAppliedPos; } + else + throw; + return nRow == m_nLastAppliedPos; } - return true; -}; - +} //define for fetching data