Simplified loops by declaring iterators with 'auto'

This commit is contained in:
archshift 2014-08-10 01:45:58 -07:00 committed by Gui Andrade
parent fb5b7a34e3
commit afbb5e2721
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
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;
if (e && offset >= e->offset && (offset + length) <= (e->offset + e->coverage)) {
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
bool Game_Data::keyExists(const wxChar* key) const {
KeyPairArray::const_iterator it( kList.begin() );
for ( ; it != kList.end(); ++it) {
for (auto it = kList.begin(); it != kList.end(); ++it) {
if (it->CompareKey(key)) {
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
void Game_Data::deleteKey(const wxChar* key) {
KeyPairArray::iterator it( kList.begin() );
for ( ; it != kList.end(); ++it) {
for (auto it = kList.begin(); it != kList.end(); ++it) {
if (it->CompareKey(key)) {
kList.erase(it);
return;
@ -118,8 +116,7 @@ void Game_Data::deleteKey(const wxChar* key) {
// Gets a string representation of the 'value' for the given key
wxString Game_Data::getString(const wxChar* key) const {
KeyPairArray::const_iterator it( kList.begin() );
for ( ; it != kList.end(); ++it) {
for (auto it = kList.begin(); it != kList.end(); ++it) {
if (it->CompareKey(key)) {
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) {
KeyPairArray::iterator it( kList.begin() );
for ( ; it != kList.end(); ++it) {
for (auto it = kList.begin(); it != kList.end(); ++it) {
if (it->CompareKey(key)) {
if( value.IsEmpty() )
kList.erase(it);

View File

@ -212,8 +212,8 @@ void AppGameDatabase::SaveToFile(const wxString& file) {
for( uint gameidx=0; gameidx<=endidx; ++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() );
}