File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -688,9 +688,9 @@ static RPCHelpMan getnetworkinfo()
688688 obj.pushKV (" connections_mn" , (int )node.connman ->GetNodeCount (ConnectionDirection::Verified));
689689 obj.pushKV (" connections_mn_in" , (int )node.connman ->GetNodeCount (ConnectionDirection::VerifiedIn));
690690 obj.pushKV (" connections_mn_out" , (int )node.connman ->GetNodeCount (ConnectionDirection::VerifiedOut));
691- std::string sem_str = SEMToString (node.connman ->GetSocketEventsMode ());
691+ std::string_view sem_str = SEMToString (node.connman ->GetSocketEventsMode ());
692692 CHECK_NONFATAL (sem_str != " unknown" );
693- obj.pushKV (" socketevents" , sem_str);
693+ obj.pushKV (" socketevents" , std::string ( sem_str) );
694694 }
695695 obj.pushKV (" networks" , GetNetworksInfo ());
696696 obj.pushKV (" relayfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ()));
Original file line number Diff line number Diff line change @@ -29,8 +29,7 @@ enum class SocketEventsMode : int8_t {
2929};
3030
3131/* Converts SocketEventsMode value to string with additional check to report modes not compiled for as unknown */
32- static std::string SEMToString (const SocketEventsMode val)
33- {
32+ constexpr std::string_view SEMToString (const SocketEventsMode val) {
3433 switch (val) {
3534 case (SocketEventsMode::Select):
3635 return " select" ;
@@ -52,19 +51,18 @@ static std::string SEMToString(const SocketEventsMode val)
5251}
5352
5453/* Converts string to SocketEventsMode value with additional check to report modes not compiled for as unknown */
55- static SocketEventsMode SEMFromString (const std::string str)
56- {
54+ constexpr SocketEventsMode SEMFromString (std::string_view str) {
5755 if (str == " select" ) { return SocketEventsMode::Select; }
5856#ifdef USE_POLL
59- else if (str == " poll" ) { return SocketEventsMode::Poll; }
57+ if (str == " poll" ) { return SocketEventsMode::Poll; }
6058#endif /* USE_POLL */
6159#ifdef USE_EPOLL
62- else if (str == " epoll" ) { return SocketEventsMode::EPoll; }
60+ if (str == " epoll" ) { return SocketEventsMode::EPoll; }
6361#endif /* USE_EPOLL */
6462#ifdef USE_KQUEUE
65- else if (str == " kqueue" ) { return SocketEventsMode::KQueue; }
63+ if (str == " kqueue" ) { return SocketEventsMode::KQueue; }
6664#endif /* USE_KQUEUE */
67- else { return SocketEventsMode::Unknown; }
65+ return SocketEventsMode::Unknown;
6866}
6967
7068/* *
You can’t perform that action at this time.
0 commit comments