void DirectoryMangaVolume::prefetch() { int theoretical_min = prefetchMin(); int theoretical_max = prefetchMax(); theoretical_max = std::max(theoretical_min+1,theoretical_max); //qWarning() << theoretical_min << " " << theoretical_max; //clear out pages that aren't necessary anymore while(m_prefetched_pages.size() > 0 && m_prefetched_pages.cbegin()->first < theoretical_min) { //qWarning() << "front unprefetched: " << m_prefetched_pages.begin()->first; m_prefetched_pages.erase(m_prefetched_pages.begin()); } while(m_prefetched_pages.size() > 0 && m_prefetched_pages.crbegin()->first > theoretical_max) { //qWarning() << "back unprefetched: " << m_prefetched_pages.crbegin()->first; //qWarning() << m_prefetched_pages.crbegin()->second.getFilename(); m_prefetched_pages.erase(--(m_prefetched_pages.crbegin().base())); } //if empty fill it in if( m_prefetched_pages.size() == 0) { for(int i=theoretical_min; i < theoretical_max; ++i) { m_prefetched_pages[i] = MangaPage(m_page_names[i]); } } //else fill in the front and back if(theoretical_min < m_prefetched_pages.cbegin()->first) { int endPos = m_prefetched_pages.cbegin()->first; for(int i=theoretical_min; i < endPos; ++i) { //qWarning() << "font prefetched: " << i; m_prefetched_pages[i] = MangaPage(m_page_names[i]); } } if(theoretical_max > m_prefetched_pages.crbegin()->first) { int startPos = m_prefetched_pages.crbegin()->first+1; for(int i=startPos; i < theoretical_max; ++i) { //qWarning() << "back prefetched: " << i; m_prefetched_pages[i] = MangaPage(m_page_names[i]); } } }
void DirectoryMangaVolume::prefetch() { int theoretical_min = prefetchMin(); int theoretical_max = prefetchMax(); theoretical_max = std::max(theoretical_min+1,theoretical_max); qWarning() << theoretical_min << " " << theoretical_max; if( m_prefetched_pages.size() == 0) { for(int i=theoretical_min; i < theoretical_max; ++i) { m_prefetched_pages[i] = MangaPage(m_page_names[i]); } } if(theoretical_min < m_prefetched_pages.cbegin()->first) { int endPos = m_prefetched_pages.cbegin()->first; for(int i=theoretical_min; i < endPos; ++i) { qWarning() << "font prefetched: " << i; m_prefetched_pages[i] = MangaPage(m_page_names[i]); } } else { while(m_prefetched_pages.cbegin()->first < theoretical_min) { qWarning() << "front unprefetched: " << m_prefetched_pages.begin()->first; m_prefetched_pages.erase(m_prefetched_pages.begin()); } } if(theoretical_max > m_prefetched_pages.crbegin()->first) { int startPos = m_prefetched_pages.crbegin()->first+1; for(int i=startPos; i < theoretical_max; ++i) { qWarning() << "back prefetched: " << i; m_prefetched_pages[i] = MangaPage(m_page_names[i]); } } else { while(m_prefetched_pages.crbegin()->first > theoretical_max) { qWarning() << "back unprefetched: " << m_prefetched_pages.crbegin()->first; qWarning() << m_prefetched_pages.crbegin()->second.getFilename(); m_prefetched_pages.erase(--(m_prefetched_pages.crbegin().base())); } } }