Simplify string operations. NFC.
authorRui Ueyama <ruiu@google.com>
Thu, 3 Mar 2016 00:51:23 +0000 (00:51 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 3 Mar 2016 00:51:23 +0000 (00:51 +0000)
llvm-svn: 262569

lld/lib/Config/Version.cpp

index 2f06d20..60687b9 100644 (file)
@@ -35,22 +35,15 @@ StringRef getLLDRevision() {
 }
 
 std::string getLLDRepositoryVersion() {
-  std::string buf;
-  llvm::raw_string_ostream OS(buf);
-  std::string Path = getLLDRepositoryPath();
-  std::string Revision = getLLDRevision();
-  if (!Path.empty() || !Revision.empty()) {
-    OS << '(';
-    if (!Path.empty())
-      OS << Path;
-    if (!Revision.empty()) {
-      if (!Path.empty())
-        OS << ' ';
-      OS << Revision;
-    }
-    OS << ')';
-  }
-  return OS.str();
+  std::string S = getLLDRepositoryPath();
+  std::string T = getLLDRevision();
+  if (S.empty() && T.empty())
+    return "";
+  if (!S.empty() && !T.empty())
+    return "(" + S + " " + T + ")";
+  if (!S.empty())
+    return "(" + S + ")";
+  return "(" + T + ")";
 }
 
 StringRef getLLDVersion() {