diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-05-13 23:25:10 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-05-13 23:31:46 +0200 |
commit | 12d82817bf32396b58c8c65645012def606680b6 (patch) | |
tree | 52c06153bf09eb9cf6c0c8457d9fa5222d75939c | |
parent | b94061902e52132489fe296c12396798700f1f35 (diff) |
refactor: simplify `FormatSubVersion` using strprintf/Join
Rather than using std::ostringstream and manually joining the
comments, use strprintf and our own `Join` helper.
-rw-r--r-- | src/clientversion.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 3a5e060a39..6b9727a158 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -5,11 +5,11 @@ #include <config/bitcoin-config.h> // IWYU pragma: keep #include <clientversion.h> +#include <util/string.h> #include <util/translation.h> #include <tinyformat.h> -#include <sstream> #include <string> #include <vector> @@ -64,19 +64,9 @@ std::string FormatFullVersion() */ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments) { - std::ostringstream ss; - ss << "/"; - ss << name << ":" << FormatVersion(nClientVersion); - if (!comments.empty()) - { - std::vector<std::string>::const_iterator it(comments.begin()); - ss << "(" << *it; - for(++it; it != comments.end(); ++it) - ss << "; " << *it; - ss << ")"; - } - ss << "/"; - return ss.str(); + std::string comments_str; + if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; ")); + return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str); } std::string CopyrightHolders(const std::string& strPrefix) |