Skip to content

Commit

Permalink
Tidy: rpc_hub.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Nov 26, 2024
1 parent 914f6db commit 3893b56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 8 additions & 10 deletions nui/include/nui/backend/rpc_hub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <string>
#include <tuple>
#include <utility>
#include <thread>
#include <functional>
#include <unordered_map>
#include <mutex>
Expand Down Expand Up @@ -40,7 +39,7 @@ namespace Nui
template <typename FunctionT>
constexpr static auto wrapFunction(FunctionT&& func)
{
return [func = std::move(func)](nlohmann::json const& args) mutable {
return [func = std::forward<FunctionT>(func)](nlohmann::json const& args) mutable {
func(args);
};
}
Expand All @@ -52,7 +51,7 @@ namespace Nui
template <typename FunctionT>
constexpr static auto wrapFunction(FunctionT&& func)
{
return [func = std::move(func)](nlohmann::json const& args) mutable {
return [func = std::forward<FunctionT>(func)](nlohmann::json const& args) mutable {
func(extractJsonMember<ArgsTypes>(args[Is])...);
};
}
Expand All @@ -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;
Expand Down Expand Up @@ -153,13 +152,15 @@ namespace Nui
template <typename Arg>
void callRemote(std::string const& name, Arg&& arg) const
{
nlohmann::json j = arg;
callRemoteImpl(name, std::move(j));
nlohmann::json json = std::forward<Arg>(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);
Expand Down Expand Up @@ -238,10 +239,7 @@ namespace Nui
}}})
.first->second.get();
}
else
{
return iter->second.get();
}
return iter->second.get();
}

private:
Expand Down

0 comments on commit 3893b56

Please sign in to comment.