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/BaseObject.cc

    r10768 r10821  
    234234    {
    235235        unsigned int i = 0;
    236         for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
     236        for (const auto & elem : this->templates_)
    237237        {
    238238            if (i == index)
    239                 return (*it);
     239                return (elem);
    240240            i++;
    241241        }
     
    269269    {
    270270        unsigned int i = 0;
    271         for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); ++it)
    272         {
    273             if (it->second != state)
     271        for (const auto & elem : this->eventSources_)
     272        {
     273            if (elem.second != state)
    274274                continue;
    275275
    276276            if (i == index)
    277                 return it->first;
     277                return elem.first;
    278278            ++i;
    279279        }
     
    296296    {
    297297        unsigned int i = 0;
    298         for (std::set<BaseObject*>::const_iterator it = this->eventListenersXML_.begin(); it != this->eventListenersXML_.end(); ++it)
     298        for (const auto & elem : this->eventListenersXML_)
    299299        {
    300300            if (i == index)
    301                 return *it;
     301                return elem;
    302302            ++i;
    303303        }
     
    358358        Event event(activate, originator, name);
    359359
    360         for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    361         {
    362             event.statename_ = (*it)->eventSources_[this];
    363             (*it)->processEvent(event);
     360        for (const auto & elem : this->eventListeners_)
     361        {
     362            event.statename_ = (elem)->eventSources_[this];
     363            (elem)->processEvent(event);
    364364        }
    365365    }
     
    370370    void BaseObject::fireEvent(Event& event)
    371371    {
    372         for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    373             (*it)->processEvent(event);
     372        for (const auto & elem : this->eventListeners_)
     373            (elem)->processEvent(event);
    374374    }
    375375
     
    474474
    475475            // iterate through all states and get the event sources
    476             for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
     476            for (auto & statename : eventnames)
    477477            {
    478                 const std::string& statename = (*it);
     478               
    479479
    480480                // if the event state is already known, continue with the next state
Note: See TracChangeset for help on using the changeset viewer.