Commit fde745d0 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Cleanup] Un-const the result of base::Version::GetString()

base::Version::GetString() returned a `const std::string`; there's no
reason to do this, since it's a new string (and not a reference to a
member). Additionally, this could potentially result in invocations of
Version::GetString() creating a copy, if the caller did something like:

std::string version_string = version.GetString();

Since the result would be a `const std::string`, a copy might be made to
fit into the non-const std::string required by the caller. Hopefully,
the compiler is smart enough to optimize this out, but it's better to
just un-const the result altogether.

Bug: None

Change-Id: I5afb69b5e1e04dab03eb8629ea7e2d124e91f755
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825460Reviewed-by: default avatarAlbert J. Wong <ajwong@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699982}
parent 75a39ca7
......@@ -151,7 +151,7 @@ int Version::CompareTo(const Version& other) const {
return CompareVersionComponents(components_, other.components_);
}
const std::string Version::GetString() const {
std::string Version::GetString() const {
DCHECK(IsValid());
std::string version_str;
size_t count = components_.size();
......
......@@ -56,7 +56,7 @@ class BASE_EXPORT Version {
int CompareToWildcardString(StringPiece wildcard_string) const;
// Return the string representation of this version.
const std::string GetString() const;
std::string GetString() const;
const std::vector<uint32_t>& components() const { return components_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment