summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-12-28 19:01:14 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-12-28 20:28:37 +0100
commit9c89caa036feb0977922f3452e324b97d13bb735 (patch)
tree175050fc5f1b584db178ab046a444657af8c812d /dbaccess/source
parentf2dafc6e2ccaee058276d8ddb02bea3c9bc095a2 (diff)
Optimize a bit RowSetCache (dbacess)
Change-Id: I051cb40b5dd854a4a104eae7124564cab8a35de1 Reviewed-on: https://gerrit.libreoffice.org/47151 Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx49
1 files changed, 29 insertions, 20 deletions
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index d635e12a7331..923a41cc8356 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -913,28 +913,31 @@ void ORowSetCache::moveWindow()
}
std::rotate(m_pMatrix->begin(), aEnd, aNewEnd);
- // now correct the iterator in our iterator vector
- // rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
- ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
- const ORowSetCacheMap::const_iterator aCacheEnd = m_aCacheIterators.end();
- for(;aCacheIter != aCacheEnd;++aCacheIter)
+ if (!m_bModified)
{
- if ( !aCacheIter->second.pRowSet->isInsertRow()
- && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
+ // now correct the iterator in our iterator vector
+ // rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ const ORowSetCacheMap::const_iterator aCacheEnd = m_aCacheIterators.end();
+ for(;aCacheIter != aCacheEnd;++aCacheIter)
{
- const ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
- if ( nDist >= nOverlapSize )
- {
- // That's from outside the overlap area; invalidate iterator.
- aCacheIter->second.aIterator = m_pMatrix->end();
- }
- else
+ if ( !aCacheIter->second.pRowSet->isInsertRow()
+ && aCacheIter->second.aIterator != m_pMatrix->end() )
{
- // Inside overlap area: move to correct position
- CHECK_MATRIX_POS( (nDist + nStartPosOffset) );
- aCacheIter->second.aIterator += nStartPosOffset;
- OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
+ const ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
+ if ( nDist >= nOverlapSize )
+ {
+ // That's from outside the overlap area; invalidate iterator.
+ aCacheIter->second.aIterator = m_pMatrix->end();
+ }
+ else
+ {
+ // Inside overlap area: move to correct position
+ CHECK_MATRIX_POS( (nDist + nStartPosOffset) );
+ aCacheIter->second.aIterator += nStartPosOffset;
+ OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
&& aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
+ }
}
}
}
@@ -1448,6 +1451,9 @@ void ORowSetCache::deleteIterator(const ORowSetBase* _pRowSet)
void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
{
+ if (m_bModified)
+ return;
+
if(_nDist)
{
// now correct the iterator in our iterator vector
@@ -1456,7 +1462,7 @@ void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
for(;aCacheIter != aCacheEnd;++aCacheIter)
{
if ( !aCacheIter->second.pRowSet->isInsertRow()
- && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
+ && aCacheIter->second.aIterator != m_pMatrix->end())
{
ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
if(nDist < _nDist)
@@ -1477,11 +1483,14 @@ void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
void ORowSetCache::rotateAllCacheIterators()
{
+ if (m_bModified)
+ return;
+
// now correct the iterator in our iterator vector
auto aCacheEnd = m_aCacheIterators.end();
for (auto aCacheIter = m_aCacheIterators.begin(); aCacheIter != aCacheEnd; ++aCacheIter)
{
- if (!aCacheIter->second.pRowSet->isInsertRow() && !m_bModified)
+ if (!aCacheIter->second.pRowSet->isInsertRow())
{
aCacheIter->second.aIterator = m_pMatrix->end();
}