refactor: Fix redundant conversion to std::string and then to std::string_view [performance-string-view-conversions]
What changed, and why it matters
This is a tiny code cleanup in Bitcoin Core's networking code. It removes an unnecessary conversion of a string-like variable to std::string before passing it to a function that accepts std::string_view. There is no security impact.
No security action needed. Treat as a normal code-quality/refactor change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/net.cpp, CConnman::ConnectNode called SplitHostPort(std::string(pszDest), port, host). The pszDest parameter is already a std::string_view-compatible type, and SplitHostPort accepts std::string_view, so the explicit std::string(pszDest) temporary was redundant. The patch removes that temporary. This is a pure refactor/performance lint fix with no behavioral or security change.
Changed components
src/net.cppCConnman::ConnectNodeInspect captured patch +1 / −1
diff --git a/src/net.cpp b/src/net.cpp
index 2c20c4aa..e5c04604 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -494,7 +494,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect,
if (const auto name_proxy = GetNameProxy()) {
std::string host;
uint16_t port{default_port};
- SplitHostPort(std::string(pszDest), port, host);
+ SplitHostPort(pszDest, port, host);
bool proxyConnectionFailed;
sock = ConnectThroughProxy(*name_proxy, host, port, proxyConnectionFailed);
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.