Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 3,149 Lines • ▼ Show 20 Lines | std::string userAgent(const Config &config) { | ||||
// Comments are checked for char compliance at startup, it is safe to add | // Comments are checked for char compliance at startup, it is safe to add | ||||
// them to the user agent string | // them to the user agent string | ||||
for (const std::string &cmt : gArgs.GetArgs("-uacomment")) { | for (const std::string &cmt : gArgs.GetArgs("-uacomment")) { | ||||
uacomments.push_back(cmt); | uacomments.push_back(cmt); | ||||
} | } | ||||
// Size compliance is checked at startup, it is safe to not check it again | // Size compliance is checked at startup, it is safe to not check it again | ||||
std::string subversion = | if (gArgs.IsArgSet("-uaclient")) { | ||||
deadalnix: You are branching twice on the same condition for pretty much the same reason (see `here`… | |||||
FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments); | return FormatSubVersionUserAgent(gArgs.GetArg("-uaclient", ""), | ||||
uacomments); | |||||
return subversion; | } | ||||
return FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments); | |||||
} | } |
You are branching twice on the same condition for pretty much the same reason (see here comment).
This is indicative of brittle design. For instance, if you take client name + version, then you can simply use the same function in both cases, but if you do not, then you can still create a default uaclient from CLIENT_NAME and CLIENT_VERSION. Either way, this current way of doing it doesn't make sense.