From aed9a737d6d72cecd8e2016bb8a64ddb3f619323 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Thu, 22 Aug 2024 02:56:01 +0300 Subject: [PATCH] Added const reference params if possible, removed less 16 size --- src/common/config.cpp | 12 ++++++------ src/common/config.h | 12 ++++++------ src/common/uint128.h | 2 +- src/core/file_format/playgo_chunk.cpp | 2 +- src/core/file_format/playgo_chunk.h | 2 +- src/core/file_format/psf.cpp | 2 +- src/core/file_format/psf.h | 2 +- src/core/libraries/avplayer/avplayer_source.cpp | 2 +- src/shader_recompiler/ir/opcodes.h | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 24db6b0392..6289e2af1f 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -189,15 +189,15 @@ void setNeoMode(bool enable) { isNeo = enable; } -void setLogType(std::string type) { +void setLogType(const std::string& type) { logType = type; } -void setLogFilter(std::string type) { +void setLogFilter(const std::string& type) { logFilter = type; } -void setUserName(std::string type) { +void setUserName(const std::string& type) { userName = type; } @@ -234,15 +234,15 @@ void setMainWindowWidth(u32 width) { void setMainWindowHeight(u32 height) { m_window_size_H = height; } -void setPkgViewer(std::vector pkgList) { +void setPkgViewer(const std::vector& pkgList) { m_pkg_viewer.resize(pkgList.size()); m_pkg_viewer = pkgList; } -void setElfViewer(std::vector elfList) { +void setElfViewer(const std::vector& elfList) { m_elf_viewer.resize(elfList.size()); m_elf_viewer = elfList; } -void setRecentFiles(std::vector recentFiles) { +void setRecentFiles(const std::vector& recentFiles) { m_recent_files.resize(recentFiles.size()); m_recent_files = recentFiles; } diff --git a/src/common/config.h b/src/common/config.h index 3006f2e2a2..f2b7fe09dc 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -43,10 +43,10 @@ void setScreenHeight(u32 height); void setFullscreenMode(bool enable); void setLanguage(u32 language); void setNeoMode(bool enable); -void setUserName(std::string type); +void setUserName(const std::string& type); -void setLogType(std::string type); -void setLogFilter(std::string type); +void setLogType(const std::string& type); +void setLogFilter(const std::string& type); void setVkValidation(bool enable); void setVkSyncValidation(bool enable); @@ -67,9 +67,9 @@ void setSliderPositonGrid(u32 pos); void setTableMode(u32 mode); void setMainWindowWidth(u32 width); void setMainWindowHeight(u32 height); -void setPkgViewer(std::vector pkgList); -void setElfViewer(std::vector elfList); -void setRecentFiles(std::vector recentFiles); +void setPkgViewer(const std::vector& pkgList); +void setElfViewer(const std::vector& elfList); +void setRecentFiles(const std::vector& recentFiles); u32 getMainWindowGeometryX(); u32 getMainWindowGeometryY(); diff --git a/src/common/uint128.h b/src/common/uint128.h index c44357916e..77c4a271d6 100644 --- a/src/common/uint128.h +++ b/src/common/uint128.h @@ -94,7 +94,7 @@ namespace Common { // This function divides a u128 by a u32 value and produces two u64 values: // the result of division and the remainder -[[nodiscard]] static inline std::pair Divide128On32(u128 dividend, u32 divisor) { +[[nodiscard]] static inline std::pair Divide128On32(const u128& dividend, u32 divisor) { u64 remainder = dividend[0] % divisor; u64 accum = dividend[0] / divisor; if (dividend[1] == 0) diff --git a/src/core/file_format/playgo_chunk.cpp b/src/core/file_format/playgo_chunk.cpp index a430b1ac1a..4e2faea451 100644 --- a/src/core/file_format/playgo_chunk.cpp +++ b/src/core/file_format/playgo_chunk.cpp @@ -60,7 +60,7 @@ bool PlaygoFile::LoadChunks(const Common::FS::IOFile& file) { return false; } -bool PlaygoFile::load_chunk_data(const Common::FS::IOFile& file, const chunk_t& chunk, +bool PlaygoFile::load_chunk_data(const Common::FS::IOFile& file, const chunk_t chunk, std::string& data) { if (file.IsOpen()) { if (file.Seek(chunk.offset)) { diff --git a/src/core/file_format/playgo_chunk.h b/src/core/file_format/playgo_chunk.h index 439e27d053..b6d38e0e1a 100644 --- a/src/core/file_format/playgo_chunk.h +++ b/src/core/file_format/playgo_chunk.h @@ -123,7 +123,7 @@ class PlaygoFile { } private: - bool load_chunk_data(const Common::FS::IOFile& file, const chunk_t& chunk, std::string& data); + bool load_chunk_data(const Common::FS::IOFile& file, const chunk_t chunk, std::string& data); private: PlaygoHeader playgoHeader; diff --git a/src/core/file_format/psf.cpp b/src/core/file_format/psf.cpp index c11dc05c8b..3d076acdce 100644 --- a/src/core/file_format/psf.cpp +++ b/src/core/file_format/psf.cpp @@ -9,7 +9,7 @@ PSF::PSF() = default; PSF::~PSF() = default; -bool PSF::open(const std::string& filepath, std::vector psfBuffer) { +bool PSF::open(const std::string& filepath, const std::vector& psfBuffer) { if (!psfBuffer.empty()) { psf.resize(psfBuffer.size()); psf = psfBuffer; diff --git a/src/core/file_format/psf.h b/src/core/file_format/psf.h index 17e515de26..9a162b1d52 100644 --- a/src/core/file_format/psf.h +++ b/src/core/file_format/psf.h @@ -35,7 +35,7 @@ class PSF { PSF(); ~PSF(); - bool open(const std::string& filepath, std::vector psfBuffer); + bool open(const std::string& filepath, const std::vector& psfBuffer); std::string GetString(const std::string& key); u32 GetInteger(const std::string& key); diff --git a/src/core/libraries/avplayer/avplayer_source.cpp b/src/core/libraries/avplayer/avplayer_source.cpp index f5479870cc..2fc360a0e4 100644 --- a/src/core/libraries/avplayer/avplayer_source.cpp +++ b/src/core/libraries/avplayer/avplayer_source.cpp @@ -82,7 +82,7 @@ static s32 CodecTypeToStreamType(AVMediaType codec_type) { } } -static f32 AVRationalToF32(const AVRational& rational) { +static f32 AVRationalToF32(const AVRational rational) { return f32(rational.num) / rational.den; } diff --git a/src/shader_recompiler/ir/opcodes.h b/src/shader_recompiler/ir/opcodes.h index 66b6022197..06f1a6117a 100644 --- a/src/shader_recompiler/ir/opcodes.h +++ b/src/shader_recompiler/ir/opcodes.h @@ -101,7 +101,7 @@ struct fmt::formatter { return ctx.begin(); } template - auto format(const Shader::IR::Opcode& op, FormatContext& ctx) const { + auto format(const Shader::IR::Opcode op, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(op)); } };