General bugfixes and improvements

This commit is contained in:
Digital Artifex
2026-06-16 16:53:37 -04:00
parent d01f880338
commit bbaefdfe88
@@ -94,7 +94,7 @@ public:
return {}; return {};
} }
if(!slideWindow(index)) if(!const_cast<SlidingCacheController*>(this)->slideWindow(index))
{ {
return {}; return {};
} }
@@ -127,7 +127,7 @@ public:
return {}; return {};
} }
if(!slideWindow(index)) if(!const_cast<SlidingCacheController*>(this)->slideWindow(index))
{ {
return {}; return {};
} }
@@ -148,7 +148,7 @@ public:
for(qsizetype i = index; i < count; ++i) for(qsizetype i = index; i < count; ++i)
{ {
T data = at(i); T data = m_cache.at(i);
if(data != T{}) if(data != T{})
{ {
@@ -184,7 +184,6 @@ public:
QMutexLocker cacheLocker(&m_cacheMutex); QMutexLocker cacheLocker(&m_cacheMutex);
m_cache.clear(); m_cache.clear();
setTotalCount(std::numeric_limits<qsizetype>::infinity());
} }
/** /**
@@ -225,10 +224,10 @@ private:
* @return True if index is within the external dataset boundary * @return True if index is within the external dataset boundary
* OR an initial fetch has not been performed. * OR an initial fetch has not been performed.
*/ */
auto externalBoundaryCheck(qsizetype index) -> bool auto externalBoundaryCheck(qsizetype index) const -> bool
{ {
return ( return (
index > 0 && index >= 0 &&
( (
m_totalCount == std::numeric_limits<qsizetype>::infinity() || m_totalCount == std::numeric_limits<qsizetype>::infinity() ||
index < m_totalCount index < m_totalCount
@@ -243,10 +242,10 @@ private:
* @param index * @param index
* @return True if index is within the internal dataset boundary * @return True if index is within the internal dataset boundary
*/ */
auto internalBoundaryCheck(qsizetype index) -> bool auto internalBoundaryCheck(qsizetype index) const -> bool
{ {
return ( return (
index > 0 && index >= 0 &&
index < m_cache.count() index < m_cache.count()
); );
} }
@@ -281,6 +280,14 @@ private:
} }
} }
if(m_totalCount == std::numeric_limits<qsizetype>::infinity())
{
if(!slideForward())
{
return false;
}
}
return true; return true;
} }
@@ -305,7 +312,14 @@ private:
movementSize -= SLIDING_CACHE_PREFETCH_THRESHOLD; movementSize -= SLIDING_CACHE_PREFETCH_THRESHOLD;
} }
if(m_totalCount != std::numeric_limits<qsizetype>::infinity())
{
m_windowOffset += movementSize; m_windowOffset += movementSize;
}
else
{
m_windowOffset = 0;
}
FetchResult<T> result = m_fetch( FetchResult<T> result = m_fetch(
m_windowOffset, m_windowOffset,
@@ -414,7 +428,7 @@ private:
* @param index Global object index * @param index Global object index
* @return * @return
*/ */
auto internalIndex(qsizetype index) -> qsizetype auto internalIndex(qsizetype index) const -> qsizetype
{ {
return index - m_windowOffset; return index - m_windowOffset;
} }