Don't default-construct std::strings and then assign them.
Change-Id: I8c994d1e6a8d2ebe52eaa4f0132e0deb2ecfa5f3
diff --git a/src/utils.cc b/src/utils.cc
index 943899d..24e0429 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -260,7 +260,7 @@
std::string DescriptorToDot(const std::string& descriptor) {
DCHECK_EQ(descriptor[0], 'L');
DCHECK_EQ(descriptor[descriptor.size()-1], ';');
- std::string dot = descriptor.substr(1, descriptor.size()-2);
+ std::string dot(descriptor.substr(1, descriptor.size() - 2));
std::replace(dot.begin(), dot.end(), '/', '.');
return dot;
}
@@ -571,7 +571,7 @@
return "";
}
- std::string art_cache = StringPrintf("%s/art-cache", data_root);
+ std::string art_cache(StringPrintf("%s/art-cache", data_root));
if (!OS::DirectoryExists(art_cache.c_str())) {
if (StringPiece(art_cache).starts_with("/tmp/")) {
@@ -589,7 +589,7 @@
}
std::string GetArtCacheFilenameOrDie(const std::string& location) {
- std::string art_cache = GetArtCacheOrDie();
+ std::string art_cache(GetArtCacheOrDie());
CHECK_EQ(location[0], '/');
std::string cache_file(location, 1); // skip leading slash
std::replace(cache_file.begin(), cache_file.end(), '/', '@');