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

@@ -9,8 +9,7 @@
#include "Common/CommonTypes.h"
#include "VideoCommon/Assets/CustomAssetLibrary.h"
void CustomPipeline::UpdatePixelData(std::shared_ptr<VideoCommon::CustomAssetLibrary>,
std::span<const u32>,
void CustomPipeline::UpdatePixelData(const VideoCommon::CustomAssetLibrary*, std::span<const u32>,
const VideoCommon::CustomAssetLibrary::AssetID&)
{
}

View File

@@ -11,7 +11,7 @@
struct CustomPipeline
{
void UpdatePixelData(std::shared_ptr<VideoCommon::CustomAssetLibrary> library,
void UpdatePixelData(const VideoCommon::CustomAssetLibrary* library,
std::span<const u32> texture_units,
const VideoCommon::CustomAssetLibrary::AssetID& material_to_load);
};

View File

@@ -3,6 +3,8 @@
#include "VideoCommon/GraphicsModSystem/Runtime/CustomShaderCache.h"
#include <utility>
#include "VideoCommon/AbstractGfx.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoEvents.h"
@@ -100,11 +102,11 @@ void CustomShaderCache::AsyncCreatePipeline(const VideoCommon::GXPipelineUid& ui
class PipelineWorkItem final : public VideoCommon::AsyncShaderCompiler::WorkItem
{
public:
PipelineWorkItem(CustomShaderCache* shader_cache, const VideoCommon::GXPipelineUid& uid,
const CustomShaderInstance& custom_shaders, PipelineIterator iterator,
const AbstractPipelineConfig& pipeline_config)
: m_shader_cache(shader_cache), m_uid(uid), m_iterator(iterator), m_config(pipeline_config),
m_custom_shaders(custom_shaders)
PipelineWorkItem(CustomShaderCache* shader_cache, VideoCommon::GXPipelineUid uid,
CustomShaderInstance custom_shaders, PipelineIterator iterator,
AbstractPipelineConfig pipeline_config)
: m_shader_cache(shader_cache), m_uid(std::move(uid)), m_iterator(iterator),
m_config(std::move(pipeline_config)), m_custom_shaders(std::move(custom_shaders))
{
SetStagesReady();
}
@@ -184,11 +186,11 @@ void CustomShaderCache::AsyncCreatePipeline(const VideoCommon::GXUberPipelineUid
class PipelineWorkItem final : public VideoCommon::AsyncShaderCompiler::WorkItem
{
public:
PipelineWorkItem(CustomShaderCache* shader_cache, const VideoCommon::GXUberPipelineUid& uid,
const CustomShaderInstance& custom_shaders, UberPipelineIterator iterator,
const AbstractPipelineConfig& pipeline_config)
: m_shader_cache(shader_cache), m_uid(uid), m_iterator(iterator), m_config(pipeline_config),
m_custom_shaders(custom_shaders)
PipelineWorkItem(CustomShaderCache* shader_cache, VideoCommon::GXUberPipelineUid uid,
CustomShaderInstance custom_shaders, UberPipelineIterator iterator,
AbstractPipelineConfig pipeline_config)
: m_shader_cache(shader_cache), m_uid(std::move(uid)), m_iterator(iterator),
m_config(std::move(pipeline_config)), m_custom_shaders(std::move(custom_shaders))
{
SetStagesReady();
}
@@ -281,8 +283,9 @@ void CustomShaderCache::QueuePixelShaderCompile(const PixelShaderUid& uid,
{
public:
PixelShaderWorkItem(CustomShaderCache* shader_cache, const PixelShaderUid& uid,
const CustomShaderInstance& custom_shaders, PixelShaderIterator iter)
: m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(custom_shaders), m_iter(iter)
CustomShaderInstance custom_shaders, PixelShaderIterator iter)
: m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(std::move(custom_shaders)),
m_iter(iter)
{
}
@@ -319,8 +322,9 @@ void CustomShaderCache::QueuePixelShaderCompile(const UberShader::PixelShaderUid
{
public:
PixelShaderWorkItem(CustomShaderCache* shader_cache, const UberShader::PixelShaderUid& uid,
const CustomShaderInstance& custom_shaders, UberPixelShaderIterator iter)
: m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(custom_shaders), m_iter(iter)
CustomShaderInstance custom_shaders, UberPixelShaderIterator iter)
: m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(std::move(custom_shaders)),
m_iter(iter)
{
}

View File

@@ -247,23 +247,22 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config)
}
}
const auto create_action =
[filesystem_library = std::move(filesystem_library)](
const std::string_view& action_name, const picojson::value& json_data,
GraphicsModConfig mod_config) -> std::unique_ptr<GraphicsModAction> {
auto action = GraphicsModActionFactory::Create(action_name, json_data, filesystem_library);
if (action == nullptr)
{
return nullptr;
}
return std::make_unique<DecoratedAction>(std::move(action), std::move(mod_config));
};
for (const auto& mod : mods)
{
for (const GraphicsModFeatureConfig& feature : mod.m_features)
{
const auto create_action =
[filesystem_library](const std::string_view& action_name,
const picojson::value& json_data,
GraphicsModConfig mod_config) -> std::unique_ptr<GraphicsModAction> {
auto action =
GraphicsModActionFactory::Create(action_name, json_data, std::move(filesystem_library));
if (action == nullptr)
{
return nullptr;
}
return std::make_unique<DecoratedAction>(std::move(action), std::move(mod_config));
};
const auto internal_group = fmt::format("{}.{}", mod.m_title, feature.m_group);
const auto add_target = [&](const GraphicsTargetConfig& target) {