Skip to content

Commit 3d24189

Browse files
committed
Merge bitcoin/bitcoin#30098: refactor: simplify FormatSubVersion using strprintf/Join
12d8281 refactor: simplify `FormatSubVersion` using strprintf/Join (Sebastian Falbesoner) Pull request description: Rather than using std::ostringstream and manually joining the comments, use strprintf and our own `Join` helper. ACKs for top commit: maflcko: utACK 12d8281 TheCharlatan: tACK 12d8281 hebasto: ACK 12d8281, I have reviewed the code and it looks OK. tdb3: ACK for 12d8281. Tree-SHA512: b9b965c4416a4c0c8727e3c4b40da4be04b14067200220492e9bed4fa35c1907fb5cdec2a30052b9e762f71da3d3cf042f43c96ab1f2523df5bb9920b44ea2a5
2 parents 695d801 + 12d8281 commit 3d24189

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/clientversion.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include <config/bitcoin-config.h> // IWYU pragma: keep
66

77
#include <clientversion.h>
8+
#include <util/string.h>
89
#include <util/translation.h>
910

1011
#include <tinyformat.h>
1112

12-
#include <sstream>
1313
#include <string>
1414
#include <vector>
1515

@@ -64,19 +64,9 @@ std::string FormatFullVersion()
6464
*/
6565
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
6666
{
67-
std::ostringstream ss;
68-
ss << "/";
69-
ss << name << ":" << FormatVersion(nClientVersion);
70-
if (!comments.empty())
71-
{
72-
std::vector<std::string>::const_iterator it(comments.begin());
73-
ss << "(" << *it;
74-
for(++it; it != comments.end(); ++it)
75-
ss << "; " << *it;
76-
ss << ")";
77-
}
78-
ss << "/";
79-
return ss.str();
67+
std::string comments_str;
68+
if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; "));
69+
return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str);
8070
}
8171

8272
std::string CopyrightHolders(const std::string& strPrefix)

0 commit comments

Comments
 (0)