Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (8 years ago)
Author:
muemart
Message:

Run clang-modernize -loop-convert

  • Again, not all possible loops were converted
  • It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc

    r10768 r10821  
    9393        {
    9494            Context temporaryContext(nullptr);
    95             for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
     95            for (auto identifier : this->identifiers_)
    9696            {
    97                 Identifier* identifier = (*it);
     97               
    9898                if (identifier->isInitialized())
    9999                    continue;
     
    127127
    128128        // finish the initialization of all identifiers
    129         for (std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it)
    130             (*it)->finishInitialization();
     129        for (const auto & initializedIdentifier : initializedIdentifiers)
     130            (initializedIdentifier)->finishInitialization();
    131131
    132132        // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway.
     
    144144    {
    145145        // check if there are any uninitialized identifiers remaining
    146         for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
    147             if (!(*it)->isInitialized())
    148                 orxout(internal_error) << "Identifier was registered late and is not initialized: " << (*it)->getName() << " / " << (*it)->getTypeInfo().name() << endl;
     146        for (const auto & elem : this->identifiers_)
     147            if (!(elem)->isInitialized())
     148                orxout(internal_error) << "Identifier was registered late and is not initialized: " << (elem)->getName() << " / " << (elem)->getTypeInfo().name() << endl;
    149149
    150150        // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy
    151151        Context temporaryContext(nullptr);
    152         for (std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1)
     152        for (const auto & initializedIdentifier : initializedIdentifiers)
    153153        {
    154             if (!(*it1)->hasFactory())
     154            if (!(initializedIdentifier)->hasFactory())
    155155                continue;
    156156
    157             Identifiable* temp = (*it1)->fabricate(&temporaryContext);
    158 
    159             for (std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2)
     157            Identifiable* temp = (initializedIdentifier)->fabricate(&temporaryContext);
     158
     159            for (const auto & elem : this->identifiers_)
    160160            {
    161                 bool isA_AccordingToRtti = (*it2)->canDynamicCastObjectToIdentifierClass(temp);
    162                 bool isA_AccordingToClassHierarchy = temp->isA((*it2));
     161                bool isA_AccordingToRtti = (elem)->canDynamicCastObjectToIdentifierClass(temp);
     162                bool isA_AccordingToClassHierarchy = temp->isA((elem));
    163163
    164164                if (isA_AccordingToRtti != isA_AccordingToClassHierarchy)
    165165                {
    166                     orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (*it1)->getName() <<
    167                         (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (*it2)->getName() << " but RTTI says the opposite." << endl;
     166                    orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (initializedIdentifier)->getName() <<
     167                        (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (elem)->getName() << " but RTTI says the opposite." << endl;
    168168                }
    169169            }
     
    184184    {
    185185        orxout(internal_status) << "Destroy class-hierarchy" << endl;
    186         for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
    187             (*it)->reset();
     186        for (const auto & elem : this->identifiers_)
     187            (elem)->reset();
    188188    }
    189189
     
    260260    {
    261261        // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)
    262         for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
    263             if ((*it)->getTypeInfo() == typeInfo)
    264                 return (*it);
     262        for (const auto & elem : this->identifiers_)
     263            if ((elem)->getTypeInfo() == typeInfo)
     264                return (elem);
    265265        return nullptr;
    266266    }
Note: See TracChangeset for help on using the changeset viewer.