[go: nahoru, domu]

[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/+/1825460
Reviewed-by: Albert J. Wong <ajwong@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699982}
diff --git a/base/version.cc b/base/version.cc
index 3ba39d4..2ee8793 100644
--- a/base/version.cc
+++ b/base/version.cc
@@ -151,7 +151,7 @@
   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();
diff --git a/base/version.h b/base/version.h
index 272cbe8..9199449d 100644
--- a/base/version.h
+++ b/base/version.h
@@ -56,7 +56,7 @@
   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_; }