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/input/InputManager.cc

    r10778 r10821  
    373373        // check whether a state has changed its EMPTY situation
    374374        bool bUpdateRequired = false;
    375         for (std::map<int, InputState*>::iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
    376         {
    377             if (it->second->hasExpired())
    378             {
    379                 it->second->resetExpiration();
     375        for (auto & elem : activeStates_)
     376        {
     377            if (elem.second->hasExpired())
     378            {
     379                elem.second->resetExpiration();
    380380                bUpdateRequired = true;
    381381            }
     
    391391
    392392        // Collect function calls for the update
    393         for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
    394             activeStatesTicked_[i]->update(time.getDeltaTime());
     393        for (auto & elem : activeStatesTicked_)
     394            elem->update(time.getDeltaTime());
    395395
    396396        // Execute all cached function calls in order
     
    401401        // If we delay the calls, then OIS and and the InputStates are not anymore
    402402        // in the call stack and can therefore be edited.
    403         for (size_t i = 0; i < this->callBuffer_.size(); ++i)
    404             this->callBuffer_[i]();
     403        for (auto & elem : this->callBuffer_)
     404            elem();
    405405
    406406        this->callBuffer_.clear();
     
    437437        // Using an std::set to avoid duplicates
    438438        std::set<InputState*> tempSet;
    439         for (unsigned int i = 0; i < devices_.size(); ++i)
    440             if (devices_[i] != nullptr)
    441                 for (unsigned int iState = 0; iState < devices_[i]->getStateListRef().size(); ++iState)
    442                     tempSet.insert(devices_[i]->getStateListRef()[iState]);
     439        for (auto & elem : devices_)
     440            if (elem != nullptr)
     441                for (unsigned int iState = 0; iState < elem->getStateListRef().size(); ++iState)
     442                    tempSet.insert(elem->getStateListRef()[iState]);
    443443
    444444        // Copy the content of the std::set back to the actual vector
    445445        activeStatesTicked_.clear();
    446         for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
    447             activeStatesTicked_.push_back(*it);
     446        for (const auto & elem : tempSet)
     447            activeStatesTicked_.push_back(elem);
    448448
    449449        // Check whether we have to change the mouse mode
Note: See TracChangeset for help on using the changeset viewer.