mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-28 05:37:36 -05:00
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:
@@ -956,7 +956,7 @@ private:
|
||||
|
||||
static bool IsRTLBinaryOp(TokenType type) { return type == TOK_ASSIGN; }
|
||||
|
||||
static bool IsBinaryOpWithPrecedence(Token tok, int precedence)
|
||||
static bool IsBinaryOpWithPrecedence(const Token& tok, int precedence)
|
||||
{
|
||||
if (!tok.IsBinaryOperator())
|
||||
return false;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
@@ -11,8 +12,8 @@ Buttons::Buttons(const std::string& name_) : Buttons(name_, name_)
|
||||
{
|
||||
}
|
||||
|
||||
Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
|
||||
: ControlGroup(ini_name, group_name, GroupType::Buttons)
|
||||
Buttons::Buttons(std::string ini_name, std::string group_name)
|
||||
: ControlGroup(std::move(ini_name), std::move(group_name), GroupType::Buttons)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class Buttons : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Buttons(const std::string& name_);
|
||||
Buttons(const std::string& ini_name, const std::string& group_name);
|
||||
Buttons(std::string ini_name, std::string group_name);
|
||||
|
||||
template <typename C>
|
||||
void GetState(C* const buttons, const C* bitmasks) const
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
ModifySettingsButton::ModifySettingsButton(std::string button_name)
|
||||
: Buttons(std::move(button_name))
|
||||
ModifySettingsButton::ModifySettingsButton(const std::string& button_name) : Buttons(button_name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ControllerEmu
|
||||
class ModifySettingsButton : public Buttons
|
||||
{
|
||||
public:
|
||||
explicit ModifySettingsButton(std::string button_name);
|
||||
explicit ModifySettingsButton(const std::string& button_name);
|
||||
|
||||
void AddInput(std::string button_name, bool toggle = false);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
#if GCADAPTER_USE_LIBUSB_IMPLEMENTATION
|
||||
@@ -477,7 +479,7 @@ static void ScanThreadFunc()
|
||||
void SetAdapterCallback(std::function<void(void)> func)
|
||||
{
|
||||
#if GCADAPTER_USE_LIBUSB_IMPLEMENTATION
|
||||
s_detect_callback = func;
|
||||
s_detect_callback = std::move(func);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
@@ -16,10 +17,11 @@
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/InputProfile.h"
|
||||
|
||||
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||
const std::string& profile_directory_name, const std::string& profile_key)
|
||||
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_directory_name(profile_directory_name),
|
||||
m_profile_key(profile_key)
|
||||
InputConfig::InputConfig(std::string ini_name, std::string gui_name,
|
||||
std::string profile_directory_name, std::string profile_key)
|
||||
: m_ini_name(std::move(ini_name)), m_gui_name(std::move(gui_name)),
|
||||
m_profile_directory_name(std::move(profile_directory_name)),
|
||||
m_profile_key(std::move(profile_key))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ class EmulatedController;
|
||||
class InputConfig
|
||||
{
|
||||
public:
|
||||
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||
const std::string& profile_directory_name, const std::string& profile_key);
|
||||
InputConfig(std::string ini_name, std::string gui_name, std::string profile_directory_name,
|
||||
std::string profile_key);
|
||||
|
||||
~InputConfig();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user