Improve usage of std::move and const references parameters

Accomplished using `run-clang-tidy` with `performance-move-const-arg,performance-unnecessary-value-param,modernize-pass-by-value`.

Changed arguments to const references, removed them where inappropriate (e.g. sink parameters). Same with std::move.

Manually reviewed each change to make sure that it makes sense, and do something more appropriate if possible.
This commit is contained in:
Martino Fontana
2026-04-06 11:37:26 +02:00
parent 33f62b0f9f
commit 95dec13203
140 changed files with 318 additions and 277 deletions

View File

@@ -166,7 +166,7 @@ void ControllerInterface::RefreshDevices(RefreshReason reason)
InvokeDevicesChangedCallbacks();
}
void ControllerInterface::PlatformPopulateDevices(std::function<void()> callback)
void ControllerInterface::PlatformPopulateDevices(const std::function<void()>& callback)
{
if (!m_is_init)
return;

View File

@@ -97,7 +97,7 @@ public:
// This is mandatory to use on device populations functions that can be called concurrently by
// more than one thread, or that are called by a single other thread.
// Without this, our devices list might end up in a mixed state.
void PlatformPopulateDevices(std::function<void()> callback);
void PlatformPopulateDevices(const std::function<void()>& callback);
bool IsInit() const { return m_is_init; }
void UpdateInput();

View File

@@ -9,6 +9,7 @@
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <fmt/format.h>
@@ -25,7 +26,8 @@ class CombinedInput final : public Device::Input
public:
using Inputs = std::pair<Device::Input*, Device::Input*>;
CombinedInput(std::string name, const Inputs& inputs) : m_name(std::move(name)), m_inputs(inputs)
CombinedInput(std::string name, Inputs inputs)
: m_name(std::move(name)), m_inputs(std::move(inputs))
{
}
ControlState GetState() const override

View File

@@ -179,7 +179,7 @@ struct Server
m_description = std::move(other.m_description);
m_address = std::move(other.m_address);
m_port = other.m_port;
m_port_info = std::move(other.m_port_info);
m_port_info = other.m_port_info;
}
Server& operator=(const Server&) = delete;

View File

@@ -13,6 +13,7 @@
#include <sstream>
#include <string>
#include <unistd.h>
#include <utility>
#include <vector>
#include "Common/FileUtil.h"
@@ -73,7 +74,7 @@ void InputBackend::PopulateDevices()
}
}
PipeDevice::PipeDevice(int fd, const std::string& name) : m_fd(fd), m_name(name)
PipeDevice::PipeDevice(int fd, std::string name) : m_fd(fd), m_name(std::move(name))
{
for (const auto& tok : s_button_tokens)
{

View File

@@ -26,7 +26,7 @@ std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* co
class PipeDevice : public Core::Device
{
public:
PipeDevice(int fd, const std::string& name);
PipeDevice(int fd, std::string name);
~PipeDevice();
Core::DeviceRemoval UpdateInput() override;

View File

@@ -505,7 +505,7 @@ void Device::RunTasks()
{
static constexpr u16 MPLUS_POLL_ADDR = WiimoteEmu::MotionPlus::PASSTHROUGH_MODE_OFFSET;
ReadData(AddressSpace::I2CBus, WiimoteEmu::MotionPlus::INACTIVE_DEVICE_ADDR, MPLUS_POLL_ADDR, 1,
[this](ReadResponse response) {
[this](const ReadResponse& response) {
if (!response)
{
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ poll failed.");