mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-03 07:11:49 +00:00
COMMON: Optimized MemoryPool::freeUnusedPages (if many pages are phased out at once, don't copy everything multiple times around)
svn-id: r40292
This commit is contained in:
parent
882c24d2ee
commit
6a632b51ad
@ -149,14 +149,16 @@ void MemoryPool::freeUnusedPages() {
|
|||||||
|
|
||||||
// printf("freed %d pages out of %d\n", (int)freedPagesCount, (int)_pages.size());
|
// printf("freed %d pages out of %d\n", (int)freedPagesCount, (int)_pages.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < _pages.size(); ) {
|
// Remove all now unused pages
|
||||||
if (_pages[i].start == NULL) {
|
size_t newSize = 0;
|
||||||
_pages.remove_at(i);
|
for (size_t i = 0; i < _pages.size(); ++i) {
|
||||||
// We just removed an entry, so we do not advance "i"
|
if (_pages[i].start != NULL) {
|
||||||
} else {
|
if (newSize != i)
|
||||||
++i;
|
_pages[newSize] = _pages[i];
|
||||||
|
++newSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_pages.resize(newSize);
|
||||||
|
|
||||||
// Reset _chunksPerPage
|
// Reset _chunksPerPage
|
||||||
_chunksPerPage = INITIAL_CHUNKS_PER_PAGE;
|
_chunksPerPage = INITIAL_CHUNKS_PER_PAGE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user