Trade potentially illegal use of size_t against container::size_type.

This commit is contained in:
Christian Speckner 2017-12-09 20:44:27 +01:00
parent bff2c7a5e7
commit c6f13ed743
3 changed files with 6 additions and 3 deletions

View File

@ -55,6 +55,7 @@ class LinkedObjectPool
public: public:
using iter = typename std::list<T>::iterator; using iter = typename std::list<T>::iterator;
using const_iter = typename std::list<T>::const_iterator; using const_iter = typename std::list<T>::const_iterator;
using size_type = typename std::list<T>::size_type;
/* /*
Create a pool of size CAPACITY; the active list starts out empty. Create a pool of size CAPACITY; the active list starts out empty.
@ -200,7 +201,7 @@ class LinkedObjectPool
#endif #endif
uInt32 capacity() const { return CAPACITY; } uInt32 capacity() const { return CAPACITY; }
size_t size() const { return myList.size(); } size_type size() const { return myList.size(); }
bool empty() const { return myList.size() == 0; } bool empty() const { return myList.size() == 0; }
bool full() const { return myList.size() >= CAPACITY; } bool full() const { return myList.size() >= CAPACITY; }

View File

@ -126,9 +126,9 @@ void RewindManager::compressStates()
uInt64 lastCycle = currentCycle; uInt64 lastCycle = currentCycle;
double expectedCycles = 76 * 262.0; // == cycles of 1 frame, TODO: use actual number of scanlines double expectedCycles = 76 * 262.0; // == cycles of 1 frame, TODO: use actual number of scanlines
double maxDelta = 0; double maxDelta = 0;
size_t removeIdx = 0; size_type removeIdx = 0;
size_t idx = myStateList.size() - 1; size_type idx = myStateList.size() - 1;
for(auto it = myStateList.last(); it != myStateList.first(); --it) for(auto it = myStateList.last(); it != myStateList.first(); --it)
{ {
cerr << *it << endl << endl; // debug code cerr << *it << endl << endl; // debug code

View File

@ -99,6 +99,8 @@ class RewindManager
} }
}; };
using size_type = Common::LinkedObjectPool<RewindState>::size_type;
// The linked-list to store states (internally it takes care of reducing // The linked-list to store states (internally it takes care of reducing
// frequent (de)-allocations) // frequent (de)-allocations)
Common::LinkedObjectPool<RewindState, MAX_SIZE> myStateList; Common::LinkedObjectPool<RewindState, MAX_SIZE> myStateList;