Qt: Remove shared_ptr copies in for loops

This commit is contained in:
Vicki Pfau 2023-08-18 22:14:40 -07:00
parent 5c2a55884b
commit 16fe12cc97
2 changed files with 11 additions and 11 deletions

View File

@ -36,7 +36,7 @@ InputController::InputController(QWidget* topLevel, QObject* parent)
mInputMapInit(&m_inputMap, &GBAInputInfo);
connect(&m_gamepadTimer, &QTimer::timeout, [this]() {
for (auto driver : m_inputDrivers) {
for (auto& driver : m_inputDrivers) {
if (driver->supportsPolling() && driver->supportsGamepads()) {
testGamepad(driver->type());
}
@ -180,7 +180,7 @@ bool InputController::loadProfile(uint32_t type, const QString& profile) {
void InputController::saveConfiguration() {
saveConfiguration(KEYBOARD);
for (auto driver : m_inputDrivers) {
for (auto& driver : m_inputDrivers) {
driver->saveConfiguration(m_config);
}
m_config->write();
@ -331,7 +331,7 @@ int InputController::mapKeyboard(int key) const {
}
void InputController::update() {
for (auto driver : m_inputDrivers) {
for (auto& driver : m_inputDrivers) {
QString profile = profileForType(driver->type());
driver->update();
QString newProfile = profileForType(driver->type());
@ -372,7 +372,7 @@ Gamepad* InputController::gamepad(uint32_t type) {
QList<Gamepad*> InputController::gamepads() {
QList<Gamepad*> pads;
for (auto driver : m_inputDrivers) {
for (auto& driver : m_inputDrivers) {
if (!driver->supportsGamepads()) {
continue;
}

View File

@ -416,7 +416,7 @@ void Window::multiplayerChanged() {
attached = multiplayer->attached();
m_playerId = multiplayer->playerId(m_controller.get());
}
for (auto action : m_nonMpActions) {
for (auto& action : m_nonMpActions) {
action->setEnabled(attached < 2);
}
}
@ -848,7 +848,7 @@ void Window::toggleFullScreen() {
}
void Window::gameStarted() {
for (auto action : m_gameActions) {
for (auto& action : m_gameActions) {
action->setEnabled(true);
}
for (auto action = m_platformActions.begin(); action != m_platformActions.end(); ++action) {
@ -929,10 +929,10 @@ void Window::gameStarted() {
}
void Window::gameStopped() {
for (auto action : m_platformActions) {
for (auto& action : m_platformActions) {
action->setEnabled(true);
}
for (auto action : m_gameActions) {
for (auto& action : m_gameActions) {
action->setEnabled(false);
}
setWindowFilePath(QString());
@ -1181,11 +1181,11 @@ void Window::updateTitle(float fps) {
MultiplayerController* multiplayer = m_controller->multiplayerController();
if (multiplayer && multiplayer->attached() > 1) {
title += tr(" - Player %1 of %2").arg(m_playerId + 1).arg(multiplayer->attached());
for (auto action : m_nonMpActions) {
for (auto& action : m_nonMpActions) {
action->setEnabled(false);
}
} else {
for (auto action : m_nonMpActions) {
for (auto& action : m_nonMpActions) {
action->setEnabled(true);
}
}
@ -1781,7 +1781,7 @@ void Window::setupMenu(QMenuBar* menubar) {
}
}, "autofire");
for (auto action : m_gameActions) {
for (auto& action : m_gameActions) {
action->setEnabled(false);
}