From 3893b562b66312141b48e699fa2aa6fa7de05c8f Mon Sep 17 00:00:00 2001 From: Tim Ebbeke Date: Tue, 26 Nov 2024 21:51:54 +0100 Subject: [PATCH] Tidy: rpc_hub.hpp --- .clang-tidy | 1 + nui/include/nui/backend/rpc_hub.hpp | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 679a7a4..88b1429 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -27,6 +27,7 @@ Checks: '-*, -readability-redundant-access-specifiers, -readability-magic-numbers, -readability-braces-around-statements, + -readability-identifier-length, hicpp-*, -hicpp-avoid-c-arrays, -hicpp-uppercase-literal-suffix, diff --git a/nui/include/nui/backend/rpc_hub.hpp b/nui/include/nui/backend/rpc_hub.hpp index 6fee3bb..7dc17fb 100644 --- a/nui/include/nui/backend/rpc_hub.hpp +++ b/nui/include/nui/backend/rpc_hub.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,7 @@ namespace Nui template constexpr static auto wrapFunction(FunctionT&& func) { - return [func = std::move(func)](nlohmann::json const& args) mutable { + return [func = std::forward(func)](nlohmann::json const& args) mutable { func(args); }; } @@ -52,7 +51,7 @@ namespace Nui template constexpr static auto wrapFunction(FunctionT&& func) { - return [func = std::move(func)](nlohmann::json const& args) mutable { + return [func = std::forward(func)](nlohmann::json const& args) mutable { func(extractJsonMember(args[Is])...); }; } @@ -78,7 +77,7 @@ namespace Nui class RpcHub { public: - RpcHub(Window& window); + explicit RpcHub(Window& window); ~RpcHub() = default; RpcHub(const RpcHub&) = delete; RpcHub& operator=(const RpcHub&) = delete; @@ -153,13 +152,15 @@ namespace Nui template void callRemote(std::string const& name, Arg&& arg) const { - nlohmann::json j = arg; - callRemoteImpl(name, std::move(j)); + nlohmann::json json = std::forward(arg); + callRemoteImpl(name, json); } void callRemote(std::string const& name, nlohmann::json const& json) const { callRemoteImpl(name, json); } + // I dont want to remove this overload in case there are some rvalue nlohmanns? + // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) void callRemote(std::string const& name, nlohmann::json&& json) const { callRemoteImpl(name, json); @@ -238,10 +239,7 @@ namespace Nui }}}) .first->second.get(); } - else - { - return iter->second.get(); - } + return iter->second.get(); } private: