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/InputDevice.h

    r10817 r10821  
    158158
    159159            // Call all the states with the held button event
    160             for (unsigned int iB = 0; iB < pressedButtons_.size(); ++iB)
    161                 for (unsigned int iS = 0; iS < inputStates_.size(); ++iS)
    162                     inputStates_[iS]->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(
    163                         this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(pressedButtons_[iB]));
     160            for (auto & button : pressedButtons_)
     161                for (auto & state : inputStates_)
     162                    state->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(
     163                        this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
    164164
    165165            // Call states with device update events
    166             for (unsigned int i = 0; i < inputStates_.size(); ++i)
    167                 inputStates_[i]->update(time.getDeltaTime(), this->getDeviceID());
     166            for (auto & elem : inputStates_)
     167                elem->update(time.getDeltaTime(), this->getDeviceID());
    168168
    169169            static_cast<DeviceClass*>(this)->updateImpl(time);
     
    196196
    197197            // Call states
    198             for (unsigned int i = 0; i < inputStates_.size(); ++i)
    199                 inputStates_[i]->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
     198            for (auto & elem : inputStates_)
     199                elem->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
    200200        }
    201201
     
    218218
    219219            // Call states
    220             for (unsigned int i = 0; i < inputStates_.size(); ++i)
    221                 inputStates_[i]->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
     220            for (auto & elem : inputStates_)
     221                elem->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
    222222        }
    223223
Note: See TracChangeset for help on using the changeset viewer.