Merge pull request #204 from archshift/auto-itr

Simplified loops by declaring iterators with 'auto'
This commit is contained in:
David Quintana 2014-08-10 22:07:31 +02:00
commit c09469a71c
3 changed files with 7 additions and 11 deletions

View File

@ -166,7 +166,7 @@ void ChunksCache::Take(void* pMallocedSrc, PX_off_t offset, int length, int cove
// By design, succeed only if the entire request is in a single cached chunk // By design, succeed only if the entire request is in a single cached chunk
int ChunksCache::Read(void* pDest, PX_off_t offset, int length) { int ChunksCache::Read(void* pDest, PX_off_t offset, int length) {
for (std::list<CacheEntry*>::iterator it = m_entries.begin(); it != m_entries.end(); it++) { for (auto it = m_entries.begin(); it != m_entries.end(); it++) {
CacheEntry* e = *it; CacheEntry* e = *it;
if (e && offset >= e->offset && (offset + length) <= (e->offset + e->coverage)) { if (e && offset >= e->offset && (offset + length) <= (e->offset + e->coverage)) {
if (it != m_entries.begin()) if (it != m_entries.begin())

View File

@ -96,8 +96,7 @@ void BaseGameDatabaseImpl::updateGame(const Game_Data& game)
// Searches the current game's data to see if the given key exists // Searches the current game's data to see if the given key exists
bool Game_Data::keyExists(const wxChar* key) const { bool Game_Data::keyExists(const wxChar* key) const {
KeyPairArray::const_iterator it( kList.begin() ); for (auto it = kList.begin(); it != kList.end(); ++it) {
for ( ; it != kList.end(); ++it) {
if (it->CompareKey(key)) { if (it->CompareKey(key)) {
return true; return true;
} }
@ -107,8 +106,7 @@ bool Game_Data::keyExists(const wxChar* key) const {
// Totally Deletes the specified key/pair value from the current game's data // Totally Deletes the specified key/pair value from the current game's data
void Game_Data::deleteKey(const wxChar* key) { void Game_Data::deleteKey(const wxChar* key) {
KeyPairArray::iterator it( kList.begin() ); for (auto it = kList.begin(); it != kList.end(); ++it) {
for ( ; it != kList.end(); ++it) {
if (it->CompareKey(key)) { if (it->CompareKey(key)) {
kList.erase(it); kList.erase(it);
return; return;
@ -118,8 +116,7 @@ void Game_Data::deleteKey(const wxChar* key) {
// Gets a string representation of the 'value' for the given key // Gets a string representation of the 'value' for the given key
wxString Game_Data::getString(const wxChar* key) const { wxString Game_Data::getString(const wxChar* key) const {
KeyPairArray::const_iterator it( kList.begin() ); for (auto it = kList.begin(); it != kList.end(); ++it) {
for ( ; it != kList.end(); ++it) {
if (it->CompareKey(key)) { if (it->CompareKey(key)) {
return it->value; return it->value;
} }
@ -128,8 +125,7 @@ wxString Game_Data::getString(const wxChar* key) const {
} }
void Game_Data::writeString(const wxString& key, const wxString& value) { void Game_Data::writeString(const wxString& key, const wxString& value) {
KeyPairArray::iterator it( kList.begin() ); for (auto it = kList.begin(); it != kList.end(); ++it) {
for ( ; it != kList.end(); ++it) {
if (it->CompareKey(key)) { if (it->CompareKey(key)) {
if( value.IsEmpty() ) if( value.IsEmpty() )
kList.erase(it); kList.erase(it);

View File

@ -212,8 +212,8 @@ void AppGameDatabase::SaveToFile(const wxString& file) {
for( uint gameidx=0; gameidx<=endidx; ++gameidx ) for( uint gameidx=0; gameidx<=endidx; ++gameidx )
{ {
const Game_Data& game( m_BlockTable[blockidx][gameidx] ); const Game_Data& game( m_BlockTable[blockidx][gameidx] );
KeyPairArray::const_iterator i(game.kList.begin());
for ( ; i != game.kList.end(); ++i) { for (auto i = game.kList.begin(); i != game.kList.end(); ++i) {
pxWriteMultiline(writer, i->toString() ); pxWriteMultiline(writer, i->toString() );
} }